home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / utilit~1 / diff21.zoo / diff21 / texinfo.tex < prev   
Encoding:
Text File  |  1993-02-07  |  122.1 KB  |  3,821 lines

  1. %% TeX macros to handle texinfo files
  2.  
  3. %   Copyright (C) 1985, 86, 88, 90, 91, 92, 1993 Free Software Foundation, Inc.
  4.  
  5. %This texinfo.tex file is free software; you can redistribute it and/or
  6. %modify it under the terms of the GNU General Public License as
  7. %published by the Free Software Foundation; either version 2, or (at
  8. %your option) any later version.
  9.  
  10. %This texinfo.tex file is distributed in the hope that it will be
  11. %useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  12. %of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. %General Public License for more details.
  14.  
  15. %You should have received a copy of the GNU General Public License
  16. %along with this texinfo.tex file; see the file COPYING.  If not, write
  17. %to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
  18. %USA.
  19.  
  20.  
  21. %In other words, you are welcome to use, share and improve this program.
  22. %You are forbidden to forbid anyone else to use, share and improve
  23. %what you give them.   Help stamp out software-hoarding!
  24.  
  25. \def\texinfoversion{2.94}
  26. \message{Loading texinfo package [Version \texinfoversion]:}
  27. \message{}
  28.  
  29. % Print the version number if in a .fmt file.
  30. \everyjob{\message{[Texinfo version \texinfoversion]}\message{}}
  31.  
  32. % Save some parts of plain tex whose names we will redefine.
  33.  
  34. \let\ptexlbrace=\{
  35. \let\ptexrbrace=\}
  36. \let\ptexdots=\dots
  37. \let\ptexdot=\.
  38. \let\ptexstar=\*
  39. \let\ptexend=\end
  40. \let\ptexbullet=\bullet
  41. \let\ptexb=\b
  42. \let\ptexc=\c
  43. \let\ptexi=\i
  44. \let\ptext=\t
  45. \let\ptexl=\l
  46. \let\ptexL=\L
  47.  
  48. \def\tie{\penalty 10000\ }     % Save plain tex definition of ~.
  49.  
  50. \message{Basics,}
  51. \chardef\other=12
  52.  
  53. % If this character appears in an error message or help string, it
  54. % starts a new line in the output.
  55. \newlinechar = `^^J
  56.  
  57. % Ignore a token.
  58. \def\gobble#1{}
  59.  
  60. \hyphenation{ap-pen-dix}
  61. \hyphenation{mini-buf-fer mini-buf-fers}
  62. \hyphenation{eshell}
  63.  
  64. % Margin to add to right of even pages, to left of odd pages.
  65. \newdimen \bindingoffset  \bindingoffset=0pt
  66. \newdimen \normaloffset   \normaloffset=\hoffset
  67. \newdimen\pagewidth \newdimen\pageheight
  68. \pagewidth=\hsize \pageheight=\vsize
  69.  
  70. % Sometimes it is convenient to have everything in the transcript file
  71. % and nothing on the terminal.  We don't just call \tracingall here,
  72. % since that produces some useless output on the terminal.
  73. %
  74. \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
  75. \def\loggingall{\tracingcommands2 \tracingstats2 
  76.    \tracingpages1 \tracingoutput1 \tracinglostchars1 
  77.    \tracingmacros2 \tracingparagraphs1 \tracingrestores1 
  78.    \showboxbreadth\maxdimen\showboxdepth\maxdimen
  79. }%
  80.  
  81. %---------------------Begin change-----------------------
  82. %
  83. %%%% For @cropmarks command.
  84. % Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986
  85. %
  86. \newdimen\cornerlong \newdimen\cornerthick
  87. \newdimen \topandbottommargin
  88. \newdimen \outerhsize \newdimen \outervsize
  89. \cornerlong=1pc\cornerthick=.3pt    % These set size of cropmarks
  90. \outerhsize=7in
  91. %\outervsize=9.5in
  92. % Alternative @smallbook page size is 9.25in
  93. \outervsize=9.25in
  94. \topandbottommargin=.75in
  95. %
  96. %---------------------End change-----------------------
  97.  
  98. % \onepageout takes a vbox as an argument.  Note that \pagecontents
  99. % does insertions itself, but you have to call it yourself.
  100. \chardef\PAGE=255  \output={\onepageout{\pagecontents\PAGE}}
  101. \def\onepageout#1{\hoffset=\normaloffset
  102. \ifodd\pageno  \advance\hoffset by \bindingoffset
  103. \else \advance\hoffset by -\bindingoffset\fi
  104. {\escapechar=`\\\relax % makes sure backslash is used in output files.
  105. \shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}%
  106. {\let\hsize=\pagewidth \makefootline}}}%
  107. \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  108.  
  109. %%%% For @cropmarks command %%%%
  110.  
  111. % Here is a modification of the main output routine for Near East Publications
  112. % This provides right-angle cropmarks at all four corners.
  113. % The contents of the page are centerlined into the cropmarks,
  114. % and any desired binding offset is added as an \hskip on either
  115. % site of the centerlined box.  (P. A. MacKay, 12 November, 1986)
  116. %
  117. \def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up
  118. {\escapechar=`\\\relax % makes sure backslash is used in output files.
  119.          \shipout
  120.          \vbox to \outervsize{\hsize=\outerhsize
  121.                  \vbox{\line{\ewtop\hfill\ewtop}}
  122.                  \nointerlineskip
  123.                  \line{\vbox{\moveleft\cornerthick\nstop}
  124.                        \hfill
  125.                        \vbox{\moveright\cornerthick\nstop}}
  126.                  \vskip \topandbottommargin
  127.                  \centerline{\ifodd\pageno\hskip\bindingoffset\fi
  128.             \vbox{
  129.             {\let\hsize=\pagewidth \makeheadline}
  130.             \pagebody{#1}
  131.             {\let\hsize=\pagewidth \makefootline}}
  132.             \ifodd\pageno\else\hskip\bindingoffset\fi}
  133.          \vskip \topandbottommargin plus1fill minus1fill
  134.                  \boxmaxdepth\cornerthick
  135.                  \line{\vbox{\moveleft\cornerthick\nsbot}
  136.                        \hfill
  137.                        \vbox{\moveright\cornerthick\nsbot}}
  138.                  \nointerlineskip
  139.                  \vbox{\line{\ewbot\hfill\ewbot}}
  140.     }}
  141.   \advancepageno 
  142.   \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  143. %
  144. % Do @cropmarks to get crop marks
  145. \def\cropmarks{\let\onepageout=\croppageout }
  146.  
  147. \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
  148. {\catcode`\@ =11
  149. \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
  150. \dimen@=\dp#1 \unvbox#1
  151. \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
  152. \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
  153. }
  154.  
  155. %
  156. % Here are the rules for the cropmarks.  Note that they are
  157. % offset so that the space between them is truly \outerhsize or \outervsize
  158. % (P. A. MacKay, 12 November, 1986)
  159. %
  160. \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
  161. \def\nstop{\vbox
  162.   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
  163. \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
  164. \def\nsbot{\vbox
  165.   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
  166.  
  167. % Parse an argument, then pass it to #1.  The argument is the rest of
  168. % the input line (except we remove a trailing comment).  #1 should be a
  169. % macro which expects an ordinary undelimited TeX argument.
  170. %
  171. \def\parsearg#1{%
  172.   \let\next = #1%
  173.   \begingroup
  174.     \obeylines
  175.     \futurelet\temp\parseargx
  176. }
  177.  
  178. % If the next token is an obeyed space (from an @example environment or
  179. % the like), remove it and recurse.  Otherwise, we're done.
  180. \def\parseargx{%
  181.   \ifx\obeyedspace\temp
  182.     \expandafter\parseargdiscardspace
  183.   \else
  184.     \expandafter\parseargline
  185.   \fi
  186. }
  187.  
  188. % Remove a single space (as the delimiter token to the macro call).
  189. {\obeyspaces %
  190.  \gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
  191.  
  192. \def\obeyedspace{\ }
  193.  
  194. {\obeylines %
  195.   \gdef\parseargline#1^^M{%
  196.     \endgroup % End of the group started in \parsearg.
  197.     %
  198.     % First remove any @c comment, then any @comment.
  199.     % Result of each macro is put in \toks0.
  200.     \argremovec #1\c\relax %
  201.     \expandafter\argremovecomment \the\toks0 \comment\relax %
  202.     %
  203.     % Call the caller's macro, saved as \next in \parsearg.
  204.     \expandafter\next\expandafter{\the\toks0}%
  205.   }%
  206. }
  207.  
  208. % Since all \c{,omment} does is throw away the argument, we can let TeX
  209. % do that for us.  The \relax here is matched by the \relax in the call
  210. % in \parseargline; it could be more or less anything, its purpose is
  211. % just to delimit the argument to the \c.
  212. \def\argremovec#1\c#2\relax{\toks0 = {#1}}
  213. \def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
  214.  
  215. % \argremovec{,omment} might leave us with trailing spaces, though; e.g.,
  216. %    @end itemize  @c foo
  217. % will have two active spaces as part of the argument with the
  218. % `itemize'.  Here we remove all active spaces from #1, and assign the
  219. % result to \toks0.
  220. %
  221. % This loses if there are any *other* active characters besides spaces
  222. % in the argument -- _ ^ +, for example -- since they get expanded.
  223. % Fortunately, Texinfo does not define any such commands.  (If it ever
  224. % does, the catcode of the characters in questionwill have to be changed
  225. % here.)  But this means we cannot call \removeactivespaces as part of
  226. % \argremovec{,omment}, since @c uses \parsearg, and thus the argument
  227. % that \parsearg gets might well have any character at all in it.
  228. \def\removeactivespaces#1{%
  229.   \begingroup
  230.     \ignoreactivespaces
  231.     \edef\temp{#1}%
  232.     \global\toks0 = \expandafter{\temp}%
  233.   \endgroup
  234. }
  235.  
  236. % Change the active space to expand to nothing.
  237. \begingroup
  238.   \obeyspaces
  239.   \gdef\ignoreactivespaces{\obeyspaces\let =\empty}
  240. \endgroup
  241.  
  242.  
  243. \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
  244.  
  245. %% These are used to keep @begin/@end levels from running away
  246. %% Call \inENV within environments (after a \begingroup)
  247. \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
  248. \def\ENVcheck{%
  249. \ifENV\errmessage{Still within an environment.  Type Return to continue.}
  250. \endgroup\fi} % This is not perfect, but it should reduce lossage
  251.  
  252. % @begin foo  is the same as @foo, for now.
  253. \newhelp\EMsimple{Type <Return> to continue.}
  254.  
  255. \outer\def\begin{\parsearg\beginxxx}
  256.  
  257. \def\beginxxx #1{%
  258. \expandafter\ifx\csname #1\endcsname\relax
  259. {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
  260. \csname #1\endcsname\fi}
  261.  
  262. % @end foo executes the definition of \Efoo.
  263. %
  264. \def\end{\parsearg\endxxx}
  265. \def\endxxx #1{%
  266.   \removeactivespaces{#1}%
  267.   \edef\endthing{\the\toks0}%
  268.   %
  269.   \expandafter\ifx\csname E\endthing\endcsname\relax
  270.     \expandafter\ifx\csname \endthing\endcsname\relax
  271.       % There's no \foo, i.e., no ``environment'' foo.
  272.       \errhelp = \EMsimple
  273.       \errmessage{Undefined command `@end \endthing'}%
  274.     \else
  275.       \unmatchedenderror\endthing
  276.     \fi
  277.   \else
  278.     % Everything's ok; the right environment has been started.
  279.     \csname E\endthing\endcsname
  280.   \fi
  281. }
  282.  
  283. % There is an environment #1, but it hasn't been started.  Give an error.
  284. \def\unmatchedenderror#1{%
  285.   \errhelp = \EMsimple
  286.   \errmessage{This `@end #1' doesn't have a matching `@#1'}%
  287. }
  288.  
  289. % Define the control sequence \E#1 to give an unmatched @end error.
  290. \def\defineunmatchedend#1{%
  291.   \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}%
  292. }
  293.  
  294.  
  295. % Single-spacing is done by various environments.
  296.  
  297. \newskip\singlespaceskip \singlespaceskip = \baselineskip
  298. \def\singlespace{%
  299. {\advance \baselineskip by -\singlespaceskip
  300. \kern \baselineskip}%
  301. \baselineskip=\singlespaceskip
  302. }
  303.  
  304. %% Simple single-character @ commands
  305.  
  306. % @@ prints an @
  307. % Kludge this until the fonts are right (grr).
  308. \def\@{{\tt \char '100}}
  309.  
  310. % This is turned off because it was never documented
  311. % and you can use @w{...} around a quote to suppress ligatures.
  312. %% Define @` and @' to be the same as ` and '
  313. %% but suppressing ligatures.
  314. %\def\`{{`}}
  315. %\def\'{{'}}
  316.  
  317. % Used to generate quoted braces.
  318.  
  319. \def\mylbrace {{\tt \char '173}}
  320. \def\myrbrace {{\tt \char '175}}
  321. \let\{=\mylbrace
  322. \let\}=\myrbrace
  323.  
  324. % @: forces normal size whitespace following.
  325. \def\:{\spacefactor=1000 }
  326.  
  327. % @* forces a line break.
  328. \def\*{\hfil\break\hbox{}\ignorespaces}
  329.  
  330. % @. is an end-of-sentence period.
  331. \def\.{.\spacefactor=3000 }
  332.  
  333. % @w prevents a word break.  Without the \leavevmode, @w at the
  334. % beginning of a paragraph, when TeX is still in vertical mode, would
  335. % produce a whole line of output instead of starting the paragraph.
  336. \def\w#1{\leavevmode\hbox{#1}}
  337.  
  338. % @group ... @end group forces ... to be all on one page, by enclosing
  339. % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
  340. % to keep its height that of a normal line.  According to the rules for
  341. % \topskip (p.114 of the TeXbook), the glue inserted is
  342. % max (\topskip - \ht (first item), 0).  If that height is large,
  343. % therefore, no glue is inserted, and the space between the headline and
  344. % the text is small, which looks bad.
  345. \def\group{\begingroup
  346.   \ifnum\catcode13=\active \else
  347.     \errhelp = \groupinvalidhelp
  348.     \errmessage{@group invalid in context where filling is enabled}%
  349.   \fi
  350.   %
  351.   % The \vtop we start below produces a box with large depth; thus, TeX
  352.   % puts \baselineskip glue before it, and (when the next line of text
  353.   % is done) \lineskip glue after it.  (See p.82 of the TeXbook.)  But
  354.   % the next line of text also gets us \parskip glue.  Final result:
  355.   % space below is slightly more than space above.
  356.   \def\Egroup{%
  357.     \egroup           % End the \vtop.
  358.     \endgroup         % End the \group.
  359.   }%
  360.   %
  361.   \vtop\bgroup
  362.     % We do @comment here in case we are called inside an environment,
  363.     % such as @example, where each end-of-line in the input causes an
  364.     % end-of-line in the output.  We don't want the end-of-line after
  365.     % the `@group' to put extra space in the output.  Since @group
  366.     % should appear on a line by itself (according to the Texinfo
  367.     % manual), we don't worry about eating any user text.
  368.     \comment
  369. }
  370. %
  371. % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
  372. % message, so this ends up printing `@group can only ...'.
  373. \newhelp\groupinvalidhelp{%
  374. group can only be used in environments such as @example,^^J%
  375. where each line of input produces a line of output.}
  376.  
  377. % @need space-in-mils
  378. % forces a page break if there is not space-in-mils remaining.
  379.  
  380. \newdimen\mil  \mil=0.001in
  381.  
  382. \def\need{\parsearg\needx}
  383.  
  384. % Old definition--didn't work.
  385. %\def\needx #1{\par %
  386. %% This method tries to make TeX break the page naturally
  387. %% if the depth of the box does not fit.
  388. %{\baselineskip=0pt%
  389. %\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000
  390. %\prevdepth=-1000pt
  391. %}}
  392.  
  393. \def\needx#1{%
  394.   % Go into vertical mode, so we don't make a big box in the middle of a
  395.   % paragraph.
  396.   \par
  397.   %
  398.   % Don't add any leading before our big empty box, but allow a page
  399.   % break, since the best break might be right here.
  400.   \allowbreak
  401.   \nointerlineskip
  402.   \vtop to #1\mil{\vfil}%
  403.   % 
  404.   % TeX does not even consider page breaks if a penalty added to the
  405.   % main vertical list is 10000 or more.  But in order to see if the
  406.   % empty box we just added fits on the page, we must make it consider
  407.   % page breaks.  On the other hand, we don't want to actually break the
  408.   % page after the empty box.  So we use a penalty of 9999.
  409.   % 
  410.   % There is an extremely small chance that TeX will actually break the
  411.   % page at this \penalty, if there are no other feasible breakpoints in
  412.   % sight.  (If the user is using lots of big @group commands, which
  413.   % almost-but-not-quite fill up a page, TeX will have a hard time doing
  414.   % good page breaking, for example.)  However, I could not construct an
  415.   % example where a page broke at this \penalty; if it happens in a real
  416.   % document, then we can reconsider our strategy.
  417.   \penalty9999
  418.   %
  419.   % Back up by the size of the box, whether we did a page break or not.
  420.   \kern -#1\mil
  421.   %
  422.   % Do not allow a page break right after this kern.
  423.   \nobreak
  424. }
  425.  
  426. % @br   forces paragraph break
  427.  
  428. \let\br = \par
  429.  
  430. % @dots{}  output some dots
  431.  
  432. \def\dots{$\ldots$}
  433.  
  434. % @page    forces the start of a new page
  435.  
  436. \def\page{\par\vfill\supereject}
  437.  
  438. % @exdent text....
  439. % outputs text on separate line in roman font, starting at standard page margin
  440.  
  441. % This records the amount of indent in the innermost environment.
  442. % That's how much \exdent should take out.
  443. \newskip\exdentamount
  444.  
  445. % This defn is used inside fill environments such as @defun.
  446. \def\exdent{\parsearg\exdentyyy}
  447. \def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}}
  448.  
  449. % This defn is used inside nofill environments such as @example.
  450. \def\nofillexdent{\parsearg\nofillexdentyyy}
  451. \def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
  452. \leftline{\hskip\leftskip{\rm#1}}}}
  453.  
  454. %\hbox{{\rm#1}}\hfil\break}}
  455.  
  456. % @include file    insert text of that file as input.
  457.  
  458. \def\include{\parsearg\includezzz}
  459. \def\includezzz #1{\def\thisfile{#1}\input #1
  460. \def\thisfile{}}
  461.  
  462. \def\thisfile{}
  463.  
  464. % @center line   outputs that line, centered
  465.  
  466. \def\center{\parsearg\centerzzz}
  467. \def\centerzzz #1{{\advance\hsize by -\leftskip
  468. \advance\hsize by -\rightskip
  469. \centerline{#1}}}
  470.  
  471. % @sp n   outputs n lines of vertical space
  472.  
  473. \def\sp{\parsearg\spxxx}
  474. \def\spxxx #1{\par \vskip #1\baselineskip}
  475.  
  476. % @comment ...line which is ignored...
  477. % @c is the same as @comment
  478. % @ignore ... @end ignore  is another way to write a comment
  479.  
  480. \def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other%
  481. \parsearg \commentxxx}
  482.  
  483. \def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 }
  484.  
  485. \let\c=\comment
  486.  
  487. % Prevent errors for section commands.
  488. % Used in @ignore and in failing conditionals.
  489. \def\ignoresections{%
  490. \let\chapter=\relax
  491. \let\unnumbered=\relax
  492. \let\top=\relax
  493. \let\unnumberedsec=\relax
  494. \let\unnumberedsection=\relax
  495. \let\unnumberedsubsec=\relax
  496. \let\unnumberedsubsection=\relax
  497. \let\unnumberedsubsubsec=\relax
  498. \let\unnumberedsubsubsection=\relax
  499. \let\section=\relax
  500. \let\subsec=\relax
  501. \let\subsubsec=\relax
  502. \let\subsection=\relax
  503. \let\subsubsection=\relax
  504. \let\appendix=\relax
  505. \let\appendixsec=\relax
  506. \let\appendixsection=\relax
  507. \let\appendixsubsec=\relax
  508. \let\appendixsubsection=\relax
  509. \let\appendixsubsubsec=\relax
  510. \let\appendixsubsubsection=\relax
  511. \let\contents=\relax
  512. \let\smallbook=\relax
  513. \let\titlepage=\relax
  514. }
  515.  
  516. % Used in nested conditionals, where we have to parse the Texinfo source
  517. % and so want to turn off most commands, in case they are used
  518. % incorrectly.  
  519. \def\ignoremorecommands{%
  520.   \let\defcv = \relax
  521.   \let\deffn = \relax
  522.   \let\deffnx = \relax
  523.   \let\defindex = \relax
  524.   \let\defivar = \relax
  525.   \let\defmac = \relax
  526.   \let\defmethod = \relax
  527.   \let\defop = \relax
  528.   \let\defopt = \relax
  529.   \let\defspec = \relax
  530.   \let\deftp = \relax
  531.   \let\deftypefn = \relax
  532.   \let\deftypefun = \relax
  533.   \let\deftypevar = \relax
  534.   \let\deftypevr = \relax
  535.   \let\defun = \relax
  536.   \let\defvar = \relax
  537.   \let\defvr = \relax
  538.   \let\ref = \relax
  539.   \let\xref = \relax
  540.   \let\pxref = \relax
  541.   \let\settitle = \relax
  542. }
  543.  
  544. % Ignore @ignore ... @end ignore.
  545. \def\ignore{\doignore{ignore}}
  546.  
  547. % Also ignore @ifinfo, @menu, and @direntry text.
  548. \def\ifinfo{\doignore{ifinfo}}
  549. \def\menu{\doignore{menu}}
  550. \def\direntry{\doignore{direntry}}
  551.  
  552. % Ignore text until a line `@end #1'.
  553. \def\doignore#1{\begingroup
  554.   % Don't complain about control sequences we have declared \outer.
  555.   \ignoresections
  556.   %
  557.   % Define a command to swallow text until we reach `@end #1'.
  558.   \long\def\doignoretext##1\end #1{\enddoignore}%
  559.   %
  560.   % Make sure that spaces turn into tokens that match what \doignoretext wants.
  561.   \catcode32 = 10
  562.   %
  563.   % And now expand that command.
  564.   \doignoretext
  565. }
  566.  
  567. % What we do to finish off ignored text.
  568. \def\enddoignore{\endgroup\ignorespaces}%
  569.  
  570. % Ignore text, except that we keep track of conditional commands for
  571. % purposes of nesting, up to an `@end #1' command.
  572. \def\nestedignore#1{%
  573.   % We must actually expand the ignored text to look for the @end
  574.   % command, so that nested ignore constructs work.  Thus, we put the
  575.   % text into a \vbox and then do nothing with the result.  To minimize
  576.   % the change of memory overflow, we follow the approach outlined on
  577.   % page 401 of the TeXbook: make the current font be a dummy font.
  578.   % 
  579.   \setbox0 = \vbox\bgroup
  580.     % Don't complain about control sequences we have declared \outer.
  581.     \ignoresections
  582.     %
  583.     % Define `@end #1' to end the box, which will in turn undefine the
  584.     % @end command again.
  585.     \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
  586.     %
  587.     % We are going to be parsing Texinfo commands.  Most cause no
  588.     % trouble when they are used incorrectly, but some commands do
  589.     % complicated argument parsing or otherwise get confused, so we
  590.     % undefine them.
  591.     %
  592.     % We can't do anything about stray @-signs, unfortunately;
  593.     % they'll produce `undefined control sequence' errors.
  594.     \ignoremorecommands
  595.     % 
  596.     % Set the current font to be \nullfont, a TeX primitive, and define
  597.     % all the font commands to also use \nullfont.  We don't use
  598.     % dummy.tfm, as suggested in the TeXbook, because not all sites
  599.     % might have that installed.  Therefore, math mode will still
  600.     % produce output, but that should be an extremely small amount of
  601.     % stuff compared to the main input.
  602.     \nullfont
  603.     \let\tenrm = \nullfont  \let\tenit = \nullfont  \let\tensl = \nullfont
  604.     \let\tenbf = \nullfont  \let\tentt = \nullfont  \let\smallcaps = \nullfont
  605.     \let\tensf = \nullfont
  606.     %
  607.     % Don't complain when characters are missing from the fonts.
  608.     \tracinglostchars = 0
  609.     %
  610.     % Don't bother to do space factor calculations.
  611.     \frenchspacing
  612.     %
  613.     % Don't report underfull hboxes.
  614.     \hbadness = 10000
  615.     %
  616.     % Do minimal line-breaking.
  617.     \pretolerance = 10000
  618. }
  619.  
  620. % @set VAR sets the variable VAR to an empty value.
  621. % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
  622. % Since we want to separate VAR from REST-OF-LINE (which might be
  623. % empty), we can't just use \parsearg; we have to insert a space of our
  624. % own to delimit the rest of the line, and then take it out again if we
  625. % didn't need it.
  626. %
  627. \def\set{\parsearg\setxxx}
  628. \def\setxxx#1{\setyyy#1 \endsetyyy}
  629. \def\setyyy#1 #2\endsetyyy{%
  630.   \def\temp{#2}%
  631.   \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty
  632.   \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted.
  633.   \fi
  634. }
  635. \def\setzzz#1#2 \endsetzzz{\expandafter\xdef\csname SET#1\endcsname{#2}}
  636.  
  637. % @clear VAR clears (i.e., unsets) the variable VAR.
  638. %
  639. \def\clear{\parsearg\clearxxx}
  640. \def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax}
  641.  
  642. % @value{foo} gets the text saved in variable foo.
  643. %
  644. \def\value#1{\expandafter
  645.         \ifx\csname SET#1\endcsname\relax
  646.             {\{No value for ``#1''\}}
  647.         \else \csname SET#1\endcsname \fi}
  648.  
  649. % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
  650. % with @set.
  651. \def\ifset{\parsearg\ifsetxxx}
  652. \def\ifsetxxx #1{%
  653.   \expandafter\ifx\csname SET#1\endcsname\relax
  654.     \expandafter\ifsetfail
  655.   \else
  656.     \expandafter\ifsetsucceed
  657.   \fi
  658. }
  659. \def\ifsetsucceed{\conditionalsucceed{ifset}}
  660. \def\ifsetfail{\nestedignore{ifset}}
  661. \defineunmatchedend{ifset}
  662.  
  663. % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
  664. % defined with @set, or has been undefined with @clear.
  665. \def\ifclear{\parsearg\ifclearxxx}
  666. \def\ifclearxxx #1{%
  667.   \expandafter\ifx\csname SET#1\endcsname\relax
  668.     \expandafter\ifclearsucceed
  669.   \else
  670.     \expandafter\ifclearfail
  671.   \fi
  672. }
  673. \def\ifclearsucceed{\conditionalsucceed{ifclear}}
  674. \def\ifclearfail{\nestedignore{ifclear}}
  675. \defineunmatchedend{ifclear}
  676.  
  677. % @iftex always succeeds; we read the text following, through @end
  678. % iftex).  But `@end iftex' should be valid only after an @iftex.
  679. \def\iftex{\conditionalsucceed{iftex}}
  680. \defineunmatchedend{iftex}
  681.  
  682. % We can't just want to start a group at @iftex (for example) and end it
  683. % at @end iftex, since then @set commands inside the conditional have no
  684. % effect (they'd get reverted at the end of the group).  So we must
  685. % define \Eiftex to redefine itself to be its previous value.  (We can't
  686. % just define it to fail again with an ``unmatched end'' error, since
  687. % the @ifset might be nested.)
  688. \def\conditionalsucceed#1{%
  689.   \edef\temp{%
  690.     % Remember the current value of \E#1.
  691.     \let\nece{prevE#1} = \nece{E#1}%
  692.     %
  693.     % At the `@end #1', redefine \E#1 to be its previous value.
  694.     \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}%
  695.   }%
  696.   \temp
  697. }
  698.  
  699. % We need to expand lots of \csname's, but we don't want to expand the
  700. % control sequences after we've constructed them.
  701. %
  702. \def\nece#1{\expandafter\noexpand\csname#1\endcsname}
  703.  
  704. % @asis just yields its argument.  Used with @table, for example.
  705. \def\asis#1{#1}
  706.  
  707. % @math means output in math mode.
  708. % We don't use $'s directly in the definition of \math because control
  709. % sequences like \math are expanded when the toc file is written.  Then,
  710. % we read the toc file back, the $'s will be normal characters (as they
  711. % should be, according to the definition of Texinfo).  So we must use a
  712. % control sequence to switch into and out of math mode.
  713. % This isn't quite enough for @math to work properly in indices, but it
  714. % seems unlikely it will ever be needed there.
  715. \let\implicitmath = $
  716. \def\math#1{\implicitmath #1\implicitmath}
  717.  
  718. % @bullet and @minus need the same treatment as @math, just above.
  719. \def\bullet{\implicitmath\ptexbullet\implicitmath}
  720. \def\minus{\implicitmath-\implicitmath}
  721.  
  722. \def\node{\ENVcheck\parsearg\nodezzz}
  723. \def\nodezzz#1{\nodexxx [#1,]}
  724. \def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
  725. \let\lastnode=\relax
  726.  
  727. \def\donoderef{\ifx\lastnode\relax\else
  728. \expandafter\expandafter\expandafter\setref{\lastnode}\fi
  729. \let\lastnode=\relax}
  730.  
  731. \def\unnumbnoderef{\ifx\lastnode\relax\else
  732. \expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi
  733. \let\lastnode=\relax}
  734.  
  735. \def\appendixnoderef{\ifx\lastnode\relax\else
  736. \expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi
  737. \let\lastnode=\relax}
  738.  
  739. \let\refill=\relax
  740.   
  741. % @setfilename is done at the beginning of every texinfo file.
  742. % So open here the files we need to have open while reading the input.
  743. % This makes it possible to make a .fmt file for texinfo.
  744. \def\setfilename{%
  745.    \readauxfile
  746.    \opencontents
  747.    \openindices
  748.    \fixbackslash  % Turn off hack to swallow `\input texinfo'.
  749.    \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
  750.    \comment % Ignore the actual filename.
  751. }
  752.  
  753. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
  754.  
  755. \def\inforef #1{\inforefzzz #1,,,,**}
  756. \def\inforefzzz #1,#2,#3,#4**{See Info file \file{\ignorespaces #3{}},
  757.   node \samp{\ignorespaces#1{}}}
  758.  
  759. \message{fonts,}
  760.  
  761. % Font-change commands.
  762.  
  763. % Texinfo supports the sans serif font style, which plain TeX does not.
  764. % So we set up a \sf analogous to plain's \rm, etc.
  765. \newfam\sffam
  766. \def\sf{\fam=\sffam \tensf}
  767. \let\li = \sf % Sometimes we call it \li, not \sf.
  768.  
  769. %% Try out Computer Modern fonts at \magstephalf
  770. \let\mainmagstep=\magstephalf
  771.  
  772. \ifx\bigger\relax
  773. \let\mainmagstep=\magstep1
  774. \font\textrm=cmr12
  775. \font\texttt=cmtt12
  776. \else
  777. \font\textrm=cmr10 scaled \mainmagstep
  778. \font\texttt=cmtt10 scaled \mainmagstep
  779. \fi
  780. % Instead of cmb10, you many want to use cmbx10.
  781. % cmbx10 is a prettier font on its own, but cmb10
  782. % looks better when embedded in a line with cmr10.
  783. \font\textbf=cmb10 scaled \mainmagstep 
  784. \font\textit=cmti10 scaled \mainmagstep
  785. \font\textsl=cmsl10 scaled \mainmagstep
  786. \font\textsf=cmss10 scaled \mainmagstep
  787. \font\textsc=cmcsc10 scaled \mainmagstep
  788. \font\texti=cmmi10 scaled \mainmagstep
  789. \font\textsy=cmsy10 scaled \mainmagstep
  790.  
  791. % A few fonts for @defun, etc.
  792. \font\defbf=cmbx10 scaled \magstep1 %was 1314
  793. \font\deftt=cmtt10 scaled \magstep1
  794. \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf}
  795.  
  796. % Fonts for indices and small examples.
  797. % We actually use the slanted font rather than the italic, 
  798. % because texinfo normally uses the slanted fonts for that.
  799. % Do not make many font distinctions in general in the index, since they
  800. % aren't very useful.
  801. \font\ninett=cmtt9
  802. \font\indrm=cmr9
  803. \font\indit=cmsl9
  804. \let\indsl=\indit
  805. \let\indtt=\ninett
  806. \let\indsf=\indrm
  807. \let\indbf=\indrm
  808. \let\indsc=\indrm
  809. \font\indi=cmmi9
  810. \font\indsy=cmsy9
  811.  
  812. % Fonts for headings
  813. \font\chaprm=cmbx12 scaled \magstep2
  814. \font\chapit=cmti12 scaled \magstep2
  815. \font\chapsl=cmsl12 scaled \magstep2
  816. \font\chaptt=cmtt12 scaled \magstep2
  817. \font\chapsf=cmss12 scaled \magstep2
  818. \let\chapbf=\chaprm
  819. \font\chapsc=cmcsc10 scaled\magstep3
  820. \font\chapi=cmmi12 scaled \magstep2
  821. \font\chapsy=cmsy10 scaled \magstep3
  822.  
  823. \font\secrm=cmbx12 scaled \magstep1
  824. \font\secit=cmti12 scaled \magstep1
  825. \font\secsl=cmsl12 scaled \magstep1
  826. \font\sectt=cmtt12 scaled \magstep1
  827. \font\secsf=cmss12 scaled \magstep1
  828. \font\secbf=cmbx12 scaled \magstep1
  829. \font\secsc=cmcsc10 scaled\magstep2
  830. \font\seci=cmmi12 scaled \magstep1
  831. \font\secsy=cmsy10 scaled \magstep2
  832.  
  833. % \font\ssecrm=cmbx10 scaled \magstep1    % This size an font looked bad.
  834. % \font\ssecit=cmti10 scaled \magstep1    % The letters were too crowded.
  835. % \font\ssecsl=cmsl10 scaled \magstep1
  836. % \font\ssectt=cmtt10 scaled \magstep1
  837. % \font\ssecsf=cmss10 scaled \magstep1
  838.  
  839. %\font\ssecrm=cmb10 scaled 1315    % Note the use of cmb rather than cmbx.
  840. %\font\ssecit=cmti10 scaled 1315    % Also, the size is a little larger than
  841. %\font\ssecsl=cmsl10 scaled 1315    % being scaled magstep1.
  842. %\font\ssectt=cmtt10 scaled 1315
  843. %\font\ssecsf=cmss10 scaled 1315
  844.  
  845. %\let\ssecbf=\ssecrm
  846.  
  847. \font\ssecrm=cmbx12 scaled \magstephalf
  848. \font\ssecit=cmti12 scaled \magstephalf
  849. \font\ssecsl=cmsl12 scaled \magstephalf
  850. \font\ssectt=cmtt12 scaled \magstephalf
  851. \font\ssecsf=cmss12 scaled \magstephalf
  852. \font\ssecbf=cmbx12 scaled \magstephalf
  853. \font\ssecsc=cmcsc10 scaled \magstep1 
  854. \font\sseci=cmmi12 scaled \magstephalf
  855. \font\ssecsy=cmsy10 scaled \magstep1
  856. % The smallcaps and symbol fonts should actually be scaled \magstep1.5,
  857. % but that is not a standard magnification.
  858.  
  859. % Fonts for title page:
  860. \font\titlerm = cmbx12 scaled \magstep3
  861. \let\authorrm = \secrm
  862.  
  863. % In order for the font changes to affect most math symbols and letters,
  864. % we have to define the \textfont of the standard families.  Since
  865. % texinfo doesn't allow for producing subscripts and superscripts, we
  866. % don't bother to reset \scriptfont and \scriptscriptfont (which would
  867. % also require loading a lot more fonts).
  868. \def\resetmathfonts{%
  869.   \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy
  870.   \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf
  871.   \textfont\ttfam = \tentt \textfont\sffam = \tensf
  872. }
  873.  
  874.  
  875. % The font-changing commands redefine the meanings of \tenSTYLE, instead
  876. % of just \STYLE.  We do this so that font changes will continue to work
  877. % in math mode, where it is the current \fam that is relevant in most
  878. % cases, not the current.  Plain TeX does, for example,
  879. % \def\bf{\fam=\bffam \tenbf}  By redefining \tenbf, we obviate the need
  880. % to redefine \bf itself.  
  881. \def\textfonts{%
  882.   \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
  883.   \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
  884.   \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
  885.   \resetmathfonts}
  886. \def\chapfonts{%
  887.   \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl 
  888.   \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
  889.   \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
  890.   \resetmathfonts}
  891. \def\secfonts{%
  892.   \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
  893.   \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
  894.   \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
  895.   \resetmathfonts}
  896. \def\subsecfonts{%
  897.   \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
  898.   \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
  899.   \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
  900.   \resetmathfonts}
  901. \def\indexfonts{%
  902.   \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl
  903.   \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc
  904.   \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy
  905.   \resetmathfonts}
  906.  
  907. % Set up the default fonts, so we can use them for creating boxes.
  908. \textfonts
  909.  
  910. % Count depth in font-changes, for error checks
  911. \newcount\fontdepth \fontdepth=0
  912.  
  913. % Fonts for short table of contents.
  914. \font\shortcontrm=cmr12
  915. \font\shortcontbf=cmbx12
  916. \font\shortcontsl=cmsl12
  917.  
  918. %% Add scribe-like font environments, plus @l for inline lisp (usually sans
  919. %% serif) and @ii for TeX italic
  920.  
  921. % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
  922. % unless the following character is such as not to need one.
  923. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
  924. \def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx}
  925.  
  926. \let\i=\smartitalic
  927. \let\var=\smartitalic
  928. \let\dfn=\smartitalic
  929. \let\emph=\smartitalic
  930. \let\cite=\smartitalic
  931.  
  932. \def\b#1{{\bf #1}}
  933. \let\strong=\b
  934.  
  935. % We can't just use \exhyphenpenalty, because that only has effect at
  936. % the end of a paragraph.  Restore normal hyphenation at the end of the
  937. % group within which \nohyphenation is presumably called.
  938. \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
  939. \def\restorehyphenation{\hyphenchar\font = `- }
  940.  
  941. \def\t#1{%
  942.   {\tt \nohyphenation \rawbackslash \frenchspacing #1}%
  943.   \null
  944. }
  945. \let\ttfont = \t
  946. %\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null}
  947. \def\samp #1{`\tclose{#1}'\null}
  948. \def\key #1{{\tt \nohyphenation \uppercase{#1}}\null}
  949. \def\ctrl #1{{\tt \rawbackslash \hat}#1}
  950.  
  951. \let\file=\samp
  952.  
  953. % @code is a modification of @t,
  954. % which makes spaces the same size as normal in the surrounding text.
  955. \def\tclose#1{%
  956.   {%
  957.     % Change normal interword space to be same as for the current font.
  958.     \spaceskip = \fontdimen2\font
  959.     %
  960.     % Switch to typewriter.
  961.     \tt
  962.     %
  963.     % But `\ ' produces the large typewriter interword space.
  964.     \def\ {{\spaceskip = 0pt{} }}%
  965.     %
  966.     % Turn off hyphenation.
  967.     \nohyphenation
  968.     % 
  969.     \rawbackslash
  970.     \frenchspacing
  971.     #1%
  972.   }%
  973.   \null
  974. }
  975. \let\code=\tclose
  976. %\let\exp=\tclose  %Was temporary
  977.  
  978. % @kbd is like @code, except that if the argument is just one @key command, 
  979. % then @kbd has no effect.
  980.  
  981. \def\xkey{\key}
  982. \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
  983. \ifx\one\xkey\ifx\threex\three \key{#2}%
  984. \else\tclose{\look}\fi
  985. \else\tclose{\look}\fi}
  986.  
  987. % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
  988. % argument is to make the input look right: @dmn{pt} instead of
  989. % @dmn{}pt.
  990. \def\dmn#1{\thinspace #1}
  991.  
  992. \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
  993.  
  994. \def\l#1{{\li #1}\null}        % 
  995.  
  996. \def\r#1{{\rm #1}}        % roman font
  997. % Use of \lowercase was suggested.
  998. \def\sc#1{{\smallcaps#1}}    % smallcaps font
  999. \def\ii#1{{\it #1}}        % italic font
  1000.  
  1001. \message{page headings,}
  1002.  
  1003. \newskip\titlepagetopglue \titlepagetopglue = 1.5in
  1004. \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
  1005.  
  1006. % First the title page.  Must do @settitle before @titlepage.
  1007. \def\titlefont#1{{\titlerm #1}}
  1008.  
  1009. \newtoks\realeverypar
  1010. \newif\ifseenauthor
  1011. \newif\iffinishedtitlepage
  1012.  
  1013. \def\shorttitlepage{\parsearg\shorttitlepagezzz}
  1014. \def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
  1015.     \endgroup\page\hbox{}\page}
  1016.  
  1017. \def\titlepage{\begingroup \parindent=0pt \textfonts
  1018.    \let\subtitlerm=\tenrm
  1019. % I deinstalled the following change because \cmr12 is undefined.
  1020. % This change was not in the ChangeLog anyway.  --rms.
  1021. %   \let\subtitlerm=\cmr12
  1022.    \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
  1023.    %
  1024.    \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
  1025.    %
  1026.    % Leave some space at the very top of the page.
  1027.    \vglue\titlepagetopglue
  1028.    %
  1029.    % Now you can print the title using @title.
  1030.    \def\title{\parsearg\titlezzz}%
  1031.    \def\titlezzz##1{\leftline{\titlefont{##1}}
  1032.             % print a rule at the page bottom also.
  1033.             \finishedtitlepagefalse
  1034.             \vskip4pt \hrule height 4pt \vskip4pt}%
  1035.    % No rule at page bottom unless we print one at the top with @title.
  1036.    \finishedtitlepagetrue
  1037.    %
  1038.    % Now you can put text using @subtitle.
  1039.    \def\subtitle{\parsearg\subtitlezzz}%
  1040.    \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
  1041.    %
  1042.    % @author should come last, but may come many times.
  1043.    \def\author{\parsearg\authorzzz}%
  1044.    \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
  1045.       {\authorfont \leftline{##1}}}%
  1046.    %  
  1047.    % Most title ``pages'' are actually two pages long, with space
  1048.    % at the top of the second.  We don't want the ragged left on the second.
  1049.    \let\oldpage = \page
  1050.    \def\page{%
  1051.       \iffinishedtitlepage\else
  1052.      \finishtitlepage
  1053.       \fi
  1054.       \oldpage
  1055.       \let\page = \oldpage
  1056.       \hbox{}}%
  1057. %   \def\page{\oldpage \hbox{}}
  1058. }
  1059.  
  1060. \def\Etitlepage{%
  1061.    \iffinishedtitlepage\else
  1062.       \finishtitlepage
  1063.    \fi
  1064.    % It is important to do the page break before ending the group,
  1065.    % because the headline and footline are only empty inside the group.
  1066.    % If we use the new definition of \page, we always get a blank page
  1067.    % after the title page, which we certainly don't want.
  1068.    \oldpage
  1069.    \endgroup
  1070.    \HEADINGSon
  1071. }
  1072.  
  1073. \def\finishtitlepage{%
  1074.    \vskip4pt \hrule height 2pt
  1075.    \vskip\titlepagebottomglue
  1076.    \finishedtitlepagetrue
  1077. }
  1078.  
  1079. %%% Set up page headings and footings.
  1080.  
  1081. \let\thispage=\folio
  1082.  
  1083. \newtoks \evenheadline    % Token sequence for heading line of even pages
  1084. \newtoks \oddheadline     % Token sequence for heading line of odd pages
  1085. \newtoks \evenfootline    % Token sequence for footing line of even pages
  1086. \newtoks \oddfootline     % Token sequence for footing line of odd pages
  1087.  
  1088. % Now make Tex use those variables
  1089. \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
  1090.                             \else \the\evenheadline \fi}}
  1091. \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
  1092.                             \else \the\evenfootline \fi}\HEADINGShook}
  1093. \let\HEADINGShook=\relax
  1094.  
  1095. % Commands to set those variables.
  1096. % For example, this is what  @headings on  does
  1097. % @evenheading @thistitle|@thispage|@thischapter
  1098. % @oddheading @thischapter|@thispage|@thistitle
  1099. % @evenfooting @thisfile||
  1100. % @oddfooting ||@thisfile
  1101.  
  1102. \def\evenheading{\parsearg\evenheadingxxx}
  1103. \def\oddheading{\parsearg\oddheadingxxx}
  1104. \def\everyheading{\parsearg\everyheadingxxx}
  1105.  
  1106. \def\evenfooting{\parsearg\evenfootingxxx}
  1107. \def\oddfooting{\parsearg\oddfootingxxx}
  1108. \def\everyfooting{\parsearg\everyfootingxxx}
  1109.  
  1110. {\catcode`\@=0 %
  1111.  
  1112. \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
  1113. \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
  1114. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1115.  
  1116. \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
  1117. \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
  1118. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1119.  
  1120. \gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish}
  1121. \gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{%
  1122. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  1123. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1124.  
  1125. \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
  1126. \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
  1127. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1128.  
  1129. \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
  1130. \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
  1131. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1132.  
  1133. \gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish}
  1134. \gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{%
  1135. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  1136. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1137. %
  1138. }% unbind the catcode of @.
  1139.  
  1140. % @headings double    turns headings on for double-sided printing.
  1141. % @headings single    turns headings on for single-sided printing.
  1142. % @headings off        turns them off.
  1143. % @headings on        same as @headings double, retained for compatibility.
  1144. % @headings after    turns on double-sided headings after this page.
  1145. % @headings doubleafter    turns on double-sided headings after this page.
  1146. % @headings singleafter turns on single-sided headings after this page.
  1147. % By default, they are off.
  1148.  
  1149. \def\headings #1 {\csname HEADINGS#1\endcsname}
  1150.  
  1151. \def\HEADINGSoff{
  1152. \global\evenheadline={\hfil} \global\evenfootline={\hfil}
  1153. \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
  1154. \HEADINGSoff
  1155. % When we turn headings on, set the page number to 1.
  1156. % For double-sided printing, put current file name in lower left corner,
  1157. % chapter name on inside top of right hand pages, document
  1158. % title on inside top of left hand pages, and page numbers on outside top
  1159. % edge of all pages.
  1160. \def\HEADINGSdouble{
  1161. %\pagealignmacro
  1162. \global\pageno=1
  1163. \global\evenfootline={\hfil}
  1164. \global\oddfootline={\hfil}
  1165. \global\evenheadline={\line{\folio\hfil\thistitle}}
  1166. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1167. }
  1168. % For single-sided printing, chapter title goes across top left of page,
  1169. % page number on top right.
  1170. \def\HEADINGSsingle{
  1171. %\pagealignmacro
  1172. \global\pageno=1
  1173. \global\evenfootline={\hfil}
  1174. \global\oddfootline={\hfil}
  1175. \global\evenheadline={\line{\thischapter\hfil\folio}}
  1176. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1177. }
  1178. \def\HEADINGSon{\HEADINGSdouble}
  1179.  
  1180. \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
  1181. \let\HEADINGSdoubleafter=\HEADINGSafter
  1182. \def\HEADINGSdoublex{%
  1183. \global\evenfootline={\hfil}
  1184. \global\oddfootline={\hfil}
  1185. \global\evenheadline={\line{\folio\hfil\thistitle}}
  1186. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1187. }
  1188.  
  1189. \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
  1190. \def\HEADINGSsinglex{%
  1191. \global\evenfootline={\hfil}
  1192. \global\oddfootline={\hfil}
  1193. \global\evenheadline={\line{\thischapter\hfil\folio}}
  1194. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1195. }
  1196.  
  1197. % Subroutines used in generating headings
  1198. % Produces Day Month Year style of output.
  1199. \def\today{\number\day\space
  1200. \ifcase\month\or
  1201. January\or February\or March\or April\or May\or June\or
  1202. July\or August\or September\or October\or November\or December\fi
  1203. \space\number\year}
  1204.  
  1205. % Use this if you want the Month Day, Year style of output.
  1206. %\def\today{\ifcase\month\or
  1207. %January\or February\or March\or April\or May\or June\or
  1208. %July\or August\or September\or October\or November\or December\fi
  1209. %\space\number\day, \number\year}
  1210.  
  1211. % @settitle line...  specifies the title of the document, for headings
  1212. % It generates no output of its own
  1213.  
  1214. \def\thistitle{No Title}
  1215. \def\settitle{\parsearg\settitlezzz}
  1216. \def\settitlezzz #1{\gdef\thistitle{#1}}
  1217.  
  1218. \message{tables,}
  1219.  
  1220. % @tabs -- simple alignment
  1221.  
  1222. % These don't work.  For one thing, \+ is defined as outer.
  1223. % So these macros cannot even be defined.
  1224.  
  1225. %\def\tabs{\parsearg\tabszzz}
  1226. %\def\tabszzz #1{\settabs\+#1\cr}
  1227. %\def\tabline{\parsearg\tablinezzz}
  1228. %\def\tablinezzz #1{\+#1\cr}
  1229. %\def\&{&}
  1230.  
  1231. % Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x).
  1232.  
  1233. % default indentation of table text
  1234. \newdimen\tableindent \tableindent=.8in
  1235. % default indentation of @itemize and @enumerate text
  1236. \newdimen\itemindent  \itemindent=.3in
  1237. % margin between end of table item and start of table text.
  1238. \newdimen\itemmargin  \itemmargin=.1in
  1239.  
  1240. % used internally for \itemindent minus \itemmargin
  1241. \newdimen\itemmax
  1242.  
  1243. % Note @table, @vtable, and @vtable define @item, @itemx, etc., with
  1244. % these defs.
  1245. % They also define \itemindex
  1246. % to index the item name in whatever manner is desired (perhaps none).
  1247.  
  1248. \def\internalBitem{\smallbreak \parsearg\itemzzz}
  1249. \def\internalBitemx{\par \parsearg\itemzzz}
  1250.  
  1251. \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
  1252. \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \par \parsearg\xitemzzz}
  1253.  
  1254. \def\internalBkitem{\smallbreak \parsearg\kitemzzz}
  1255. \def\internalBkitemx{\par \parsearg\kitemzzz}
  1256.  
  1257. \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}%
  1258.                  \itemzzz {#1}}
  1259.  
  1260. \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}%
  1261.                  \itemzzz {#1}}
  1262.  
  1263. \def\itemzzz #1{\begingroup %
  1264.   \advance\hsize by -\rightskip
  1265.   \advance\hsize by -\tableindent
  1266.   \setbox0=\hbox{\itemfont{#1}}%
  1267.   \itemindex{#1}%
  1268.   \nobreak % This prevents a break before @itemx.
  1269.   %
  1270.   % Be sure we are not still in the middle of a paragraph.
  1271.   \parskip=0in
  1272.   \par
  1273.   %
  1274.   % If the item text does not fit in the space we have, put it on a line
  1275.   % by itself, and do not allow a page break either before or after that
  1276.   % line.  We do not start a paragraph here because then if the next
  1277.   % command is, e.g., @kindex, the whatsit would get put into the
  1278.   % horizontal list on a line by itself, resulting in extra blank space.
  1279.   \ifdim \wd0>\itemmax
  1280.     \setbox0=\hbox{\hskip \leftskip \hskip -\tableindent \unhbox0}\box0
  1281.     \nobreak
  1282.   \else
  1283.     % The item text fits into the space.  Start a paragraph, so that the
  1284.     % following text (if any) will end up on the same line.  Since that
  1285.     % text will be indented by \tableindent, we make the item text be in
  1286.     % a zero-width box.
  1287.     \noindent
  1288.     \rlap{\hskip -\tableindent\box0}%
  1289.     \ignorespaces
  1290.   \fi
  1291.   \endgroup
  1292. }
  1293.  
  1294. \def\item{\errmessage{@item while not in a table}}
  1295. \def\itemx{\errmessage{@itemx while not in a table}}
  1296. \def\kitem{\errmessage{@kitem while not in a table}}
  1297. \def\kitemx{\errmessage{@kitemx while not in a table}}
  1298. \def\xitem{\errmessage{@xitem while not in a table}}
  1299. \def\xitemx{\errmessage{@xitemx while not in a table}}
  1300.  
  1301. %% Contains a kludge to get @end[description] to work
  1302. \def\description{\tablez{\dontindex}{1}{}{}{}{}}
  1303.  
  1304. \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
  1305. {\obeylines\obeyspaces%
  1306. \gdef\tablex #1^^M{%
  1307. \tabley\dontindex#1        \endtabley}}
  1308.  
  1309. \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
  1310. {\obeylines\obeyspaces%
  1311. \gdef\ftablex #1^^M{%
  1312. \tabley\fnitemindex#1        \endtabley
  1313. \def\Eftable{\endgraf\endgroup\afterenvbreak}%
  1314. \let\Etable=\relax}}
  1315.  
  1316. \def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex}
  1317. {\obeylines\obeyspaces%
  1318. \gdef\vtablex #1^^M{%
  1319. \tabley\vritemindex#1        \endtabley
  1320. \def\Evtable{\endgraf\endgroup\afterenvbreak}%
  1321. \let\Etable=\relax}}
  1322.  
  1323. \def\dontindex #1{}
  1324. \def\fnitemindex #1{\doind {fn}{\code{#1}}}%
  1325. \def\vritemindex #1{\doind {vr}{\code{#1}}}%
  1326.  
  1327. {\obeyspaces %
  1328. \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
  1329. \tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
  1330.  
  1331. \def\tablez #1#2#3#4#5#6{%
  1332. \aboveenvbreak %
  1333. \begingroup %
  1334. \def\Edescription{\Etable}% Neccessary kludge.
  1335. \let\itemindex=#1%
  1336. \ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
  1337. \ifnum 0#4>0 \tableindent=#4\mil \fi %
  1338. \ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
  1339. \def\itemfont{#2}%
  1340. \itemmax=\tableindent %
  1341. \advance \itemmax by -\itemmargin %
  1342. \advance \leftskip by \tableindent %
  1343. \exdentamount=\tableindent
  1344. \parindent = 0pt
  1345. \parskip = \smallskipamount
  1346. \ifdim \parskip=0pt \parskip=2pt \fi%
  1347. \def\Etable{\endgraf\endgroup\afterenvbreak}%
  1348. \let\item = \internalBitem %
  1349. \let\itemx = \internalBitemx %
  1350. \let\kitem = \internalBkitem %
  1351. \let\kitemx = \internalBkitemx %
  1352. \let\xitem = \internalBxitem %
  1353. \let\xitemx = \internalBxitemx %
  1354. }
  1355.  
  1356. % This is the counter used by @enumerate, which is really @itemize
  1357.  
  1358. \newcount \itemno
  1359.  
  1360. \def\itemize{\parsearg\itemizezzz}
  1361.  
  1362. \def\itemizezzz #1{%
  1363.   \begingroup % ended by the @end itemsize
  1364.   \itemizey {#1}{\Eitemize}
  1365. }
  1366.  
  1367. \def\itemizey #1#2{%
  1368. \aboveenvbreak %
  1369. \itemmax=\itemindent %
  1370. \advance \itemmax by -\itemmargin %
  1371. \advance \leftskip by \itemindent %
  1372. \exdentamount=\itemindent
  1373. \parindent = 0pt %
  1374. \parskip = \smallskipamount %
  1375. \ifdim \parskip=0pt \parskip=2pt \fi%
  1376. \def#2{\endgraf\endgroup\afterenvbreak}%
  1377. \def\itemcontents{#1}%
  1378. \let\item=\itemizeitem}
  1379.  
  1380. % Set sfcode to normal for the chars that usually have another value.
  1381. % These are `.?!:;,'
  1382. \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
  1383.   \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
  1384.  
  1385. % \splitoff TOKENS\endmark defines \first to be the first token in
  1386. % TOKENS, and \rest to be the remainder.
  1387. \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
  1388.  
  1389. % Allow an optional argument of an uppercase letter, lowercase letter,
  1390. % or number, to specify the first label in the enumerated list.  No
  1391. % argument is the same as `1'.
  1392. \def\enumerate{\parsearg\enumeratezzz}
  1393. \def\enumeratezzz #1{\enumeratey #1  \endenumeratey}
  1394. \def\enumeratey #1 #2\endenumeratey{%
  1395.   \begingroup % ended by the @end enumerate
  1396.   %
  1397.   % If we were given no argument, pretend we were given `1'.
  1398.   \def\thearg{#1}%
  1399.   \ifx\thearg\empty \def\thearg{1}\fi
  1400.   %
  1401.   % Detect if the argument is a single token.  If so, it might be a
  1402.   % letter.  Otherwise, the only valid thing it can be is a number.
  1403.   % (We will always have one token, because of the test we just made.
  1404.   % This is a good thing, since \splitoff doesn't work given nothing at
  1405.   % all -- the first parameter is undelimited.)
  1406.   \expandafter\splitoff\thearg\endmark
  1407.   \ifx\rest\empty
  1408.     % Only one token in the argument.  It could still be anything.
  1409.     % A ``lowercase letter'' is one whose \lccode is nonzero.
  1410.     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
  1411.     %   not equal to itself.
  1412.     % Otherwise, we assume it's a number.
  1413.     % 
  1414.     % We need the \relax at the end of the \ifnum lines to stop TeX from
  1415.     % continuing to look for a <number>.
  1416.     % 
  1417.     \ifnum\lccode\expandafter`\thearg=0\relax 
  1418.       \numericenumerate % a number (we hope)
  1419.     \else
  1420.       % It's a letter.
  1421.       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
  1422.         \lowercaseenumerate % lowercase letter
  1423.       \else
  1424.         \uppercaseenumerate % uppercase letter
  1425.       \fi
  1426.     \fi
  1427.   \else
  1428.     % Multiple tokens in the argument.  We hope it's a number.
  1429.     \numericenumerate
  1430.   \fi
  1431. }
  1432.  
  1433. % An @enumerate whose labels are integers.  The starting integer is
  1434. % given in \thearg.
  1435. \def\numericenumerate{%
  1436.   \itemno = \thearg
  1437.   \startenumeration{\the\itemno}%
  1438. }
  1439.  
  1440. % The starting (lowercase) letter is in \thearg.
  1441. \def\lowercaseenumerate{%
  1442.   \itemno = \expandafter`\thearg
  1443.   \startenumeration{%
  1444.     % Be sure we're not beyond the end of the alphabet.
  1445.     \ifnum\itemno=0
  1446.       \errmessage{No more lowercase letters in @enumerate; get a bigger
  1447.                   alphabet}%
  1448.     \fi
  1449.     \char\lccode\itemno
  1450.   }%
  1451. }
  1452.  
  1453. % The starting (uppercase) letter is in \thearg.
  1454. \def\uppercaseenumerate{%
  1455.   \itemno = \expandafter`\thearg
  1456.   \startenumeration{%
  1457.     % Be sure we're not beyond the end of the alphabet.
  1458.     \ifnum\itemno=0
  1459.       \errmessage{No more uppercase letters in @enumerate; get a bigger
  1460.                   alphabet}
  1461.     \fi
  1462.     \char\uccode\itemno
  1463.   }%
  1464. }
  1465.  
  1466. % Call itemizey, adding a period to the first argument and supplying the
  1467. % common last two arguments.  Also subtract one from the initial value in
  1468. % \itemno, since @item increments \itemno.
  1469. \def\startenumeration#1{%
  1470.   \advance\itemno by -1
  1471.   \itemizey{#1.}\Eenumerate\flushcr
  1472. }
  1473.  
  1474. % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
  1475. % to @enumerate.
  1476. \def\alphaenumerate{\enumerate{a}}
  1477. \def\capsenumerate{\enumerate{A}}
  1478. \def\Ealphaenumerate{\Eenumerate}
  1479. \def\Ecapsenumerate{\Eenumerate}
  1480.  
  1481. % Definition of @item while inside @itemize.
  1482.  
  1483. \def\itemizeitem{%
  1484. \advance\itemno by 1
  1485. {\let\par=\endgraf \smallbreak}%
  1486. \ifhmode \errmessage{\in hmode at itemizeitem}\fi
  1487. {\parskip=0in \hskip 0pt
  1488. \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
  1489. \vadjust{\penalty 1200}}%
  1490. \flushcr}
  1491.  
  1492. \message{indexing,}
  1493. % Index generation facilities
  1494.  
  1495. % Define \newwrite to be identical to plain tex's \newwrite
  1496. % except not \outer, so it can be used within \newindex.
  1497. {\catcode`\@=11
  1498. \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
  1499.  
  1500. % \newindex {foo} defines an index named foo.
  1501. % It automatically defines \fooindex such that
  1502. % \fooindex ...rest of line... puts an entry in the index foo.
  1503. % It also defines \fooindfile to be the number of the output channel for
  1504. % the file that    accumulates this index.  The file's extension is foo.
  1505. % The name of an index should be no more than 2 characters long
  1506. % for the sake of vms.
  1507.  
  1508. \def\newindex #1{
  1509. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  1510. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  1511. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1512. \noexpand\doindex {#1}}
  1513. }
  1514.  
  1515. % @defindex foo  ==  \newindex{foo}
  1516.  
  1517. \def\defindex{\parsearg\newindex}
  1518.  
  1519. % Define @defcodeindex, like @defindex except put all entries in @code.
  1520.  
  1521. \def\newcodeindex #1{
  1522. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  1523. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  1524. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1525. \noexpand\docodeindex {#1}}
  1526. }
  1527.  
  1528. \def\defcodeindex{\parsearg\newcodeindex}
  1529.  
  1530. % @synindex foo bar    makes index foo feed into index bar.
  1531. % Do this instead of @defindex foo if you don't want it as a separate index.
  1532. \def\synindex #1 #2 {%
  1533. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  1534. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  1535. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1536. \noexpand\doindex {#2}}%
  1537. }
  1538.  
  1539. % @syncodeindex foo bar   similar, but put all entries made for index foo
  1540. % inside @code.
  1541. \def\syncodeindex #1 #2 {%
  1542. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  1543. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  1544. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1545. \noexpand\docodeindex {#2}}%
  1546. }
  1547.  
  1548. % Define \doindex, the driver for all \fooindex macros.
  1549. % Argument #1 is generated by the calling \fooindex macro,
  1550. %  and it is "foo", the name of the index.
  1551.  
  1552. % \doindex just uses \parsearg; it calls \doind for the actual work.
  1553. % This is because \doind is more useful to call from other macros.
  1554.  
  1555. % There is also \dosubind {index}{topic}{subtopic}
  1556. % which makes an entry in a two-level index such as the operation index.
  1557.  
  1558. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
  1559. \def\singleindexer #1{\doind{\indexname}{#1}}
  1560.  
  1561. % like the previous two, but they put @code around the argument.
  1562. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
  1563. \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
  1564.  
  1565. \def\indexdummies{%
  1566. \def\_{{\realbackslash _}}%
  1567. \def\w{\realbackslash w }%
  1568. \def\bf{\realbackslash bf }%
  1569. \def\rm{\realbackslash rm }%
  1570. \def\sl{\realbackslash sl }%
  1571. \def\sf{\realbackslash sf}%
  1572. \def\tt{\realbackslash tt}%
  1573. \def\gtr{\realbackslash gtr}%
  1574. \def\less{\realbackslash less}%
  1575. \def\hat{\realbackslash hat}%
  1576. \def\char{\realbackslash char}%
  1577. \def\TeX{\realbackslash TeX}%
  1578. \def\dots{\realbackslash dots }%
  1579. \def\copyright{\realbackslash copyright }%
  1580. \def\tclose##1{\realbackslash tclose {##1}}%
  1581. \def\code##1{\realbackslash code {##1}}%
  1582. \def\samp##1{\realbackslash samp {##1}}%
  1583. \def\t##1{\realbackslash r {##1}}%
  1584. \def\r##1{\realbackslash r {##1}}%
  1585. \def\i##1{\realbackslash i {##1}}%
  1586. \def\b##1{\realbackslash b {##1}}%
  1587. \def\cite##1{\realbackslash cite {##1}}%
  1588. \def\key##1{\realbackslash key {##1}}%
  1589. \def\file##1{\realbackslash file {##1}}%
  1590. \def\var##1{\realbackslash var {##1}}%
  1591. \def\kbd##1{\realbackslash kbd {##1}}%
  1592. }
  1593.  
  1594. % \indexnofonts no-ops all font-change commands.
  1595. % This is used when outputting the strings to sort the index by.
  1596. \def\indexdummyfont#1{#1}
  1597. \def\indexdummytex{TeX}
  1598. \def\indexdummydots{...}
  1599.  
  1600. \def\indexnofonts{%
  1601. \let\w=\indexdummyfont
  1602. \let\t=\indexdummyfont
  1603. \let\r=\indexdummyfont
  1604. \let\i=\indexdummyfont
  1605. \let\b=\indexdummyfont
  1606. \let\emph=\indexdummyfont
  1607. \let\strong=\indexdummyfont
  1608. \let\cite=\indexdummyfont
  1609. \let\sc=\indexdummyfont
  1610. %Don't no-op \tt, since it isn't a user-level command
  1611. % and is used in the definitions of the active chars like <, >, |...
  1612. %\let\tt=\indexdummyfont
  1613. \let\tclose=\indexdummyfont
  1614. \let\code=\indexdummyfont
  1615. \let\file=\indexdummyfont
  1616. \let\samp=\indexdummyfont
  1617. \let\kbd=\indexdummyfont
  1618. \let\key=\indexdummyfont
  1619. \let\var=\indexdummyfont
  1620. \let\TeX=\indexdummytex
  1621. \let\dots=\indexdummydots
  1622. }
  1623.  
  1624. % To define \realbackslash, we must make \ not be an escape.
  1625. % We must first make another character (@) an escape
  1626. % so we do not become unable to do a definition.
  1627.  
  1628. {\catcode`\@=0 \catcode`\\=\other
  1629. @gdef@realbackslash{\}}
  1630.  
  1631. \let\indexbackslash=0  %overridden during \printindex.
  1632.  
  1633. \def\doind #1#2{%
  1634. {\count10=\lastpenalty%
  1635. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1636. \escapechar=`\\%
  1637. {\let\folio=0% Expand all macros now EXCEPT \folio
  1638. \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
  1639. % so it will be output as is; and it will print as backslash in the indx.
  1640. %
  1641. % Now process the index-string once, with all font commands turned off,
  1642. % to get the string to sort the index by.
  1643. {\indexnofonts%
  1644. \xdef\temp1{#2}%
  1645. }%
  1646. % Now produce the complete index entry.  We process the index-string again,
  1647. % this time with font commands expanded, to get what to print in the index.
  1648. \edef\temp{%
  1649. \write \csname#1indfile\endcsname{%
  1650. \realbackslash entry {\temp1}{\folio}{#2}}}%
  1651. \temp}%
  1652. }\penalty\count10}}
  1653.  
  1654. \def\dosubind #1#2#3{%
  1655. {\count10=\lastpenalty%
  1656. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1657. \escapechar=`\\%
  1658. {\let\folio=0%
  1659. \def\rawbackslashxx{\indexbackslash}%
  1660. %
  1661. % Now process the index-string once, with all font commands turned off,
  1662. % to get the string to sort the index by.
  1663. {\indexnofonts%
  1664. \xdef\temp1{#2 #3}%
  1665. }%
  1666. % Now produce the complete index entry.  We process the index-string again,
  1667. % this time with font commands expanded, to get what to print in the index.
  1668. \edef\temp{%
  1669. \write \csname#1indfile\endcsname{%
  1670. \realbackslash entry {\temp1}{\folio}{#2}{#3}}}%
  1671. \temp}%
  1672. }\penalty\count10}}
  1673.  
  1674. % The index entry written in the file actually looks like
  1675. %  \entry {sortstring}{page}{topic}
  1676. % or
  1677. %  \entry {sortstring}{page}{topic}{subtopic}
  1678. % The texindex program reads in these files and writes files
  1679. % containing these kinds of lines:
  1680. %  \initial {c}
  1681. %     before the first topic whose initial is c
  1682. %  \entry {topic}{pagelist}
  1683. %     for a topic that is used without subtopics
  1684. %  \primary {topic}
  1685. %     for the beginning of a topic that is used with subtopics
  1686. %  \secondary {subtopic}{pagelist}
  1687. %     for each subtopic.
  1688.  
  1689. % Define the user-accessible indexing commands 
  1690. % @findex, @vindex, @kindex, @cindex.
  1691.  
  1692. \def\findex {\fnindex}
  1693. \def\kindex {\kyindex}
  1694. \def\cindex {\cpindex}
  1695. \def\vindex {\vrindex}
  1696. \def\tindex {\tpindex}
  1697. \def\pindex {\pgindex}
  1698.  
  1699. \def\cindexsub {\begingroup\obeylines\cindexsub}
  1700. {\obeylines %
  1701. \gdef\cindexsub "#1" #2^^M{\endgroup %
  1702. \dosubind{cp}{#2}{#1}}}
  1703.  
  1704. % Define the macros used in formatting output of the sorted index material.
  1705.  
  1706. % This is what you call to cause a particular index to get printed.
  1707. % Write
  1708. % @unnumbered Function Index
  1709. % @printindex fn
  1710.  
  1711. \def\printindex{\parsearg\doprintindex}
  1712.  
  1713. \def\doprintindex#1{%
  1714.   \tex
  1715.   \dobreak \chapheadingskip {10000}
  1716.   \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other
  1717.   \catcode`\$=\other\catcode`\_=\other
  1718.   \catcode`\~=\other
  1719.   %
  1720.   % The following don't help, since the chars were translated
  1721.   % when the raw index was written, and their fonts were discarded
  1722.   % due to \indexnofonts.
  1723.   %\catcode`\"=\active
  1724.   %\catcode`\^=\active
  1725.   %\catcode`\_=\active
  1726.   %\catcode`\|=\active
  1727.   %\catcode`\<=\active
  1728.   %\catcode`\>=\active
  1729.   % %
  1730.   \def\indexbackslash{\rawbackslashxx}
  1731.   \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt
  1732.   \begindoublecolumns
  1733.   %
  1734.   % See if the index file exists and is nonempty.
  1735.   \openin 1 \jobname.#1s
  1736.   \ifeof 1 
  1737.     % \enddoublecolumns gets confused if there is no text in the index,
  1738.     % and it loses the chapter title and the aux file entries for the
  1739.     % index.  The easiest way to prevent this problem is to make sure
  1740.     % there is some text.
  1741.     (Index is nonexistent)
  1742.     \else
  1743.     %
  1744.     % If the index file exists but is empty, then \openin leaves \ifeof
  1745.     % false.  We have to make TeX try to read something from the file, so
  1746.     % it can discover if there is anything in it.
  1747.     \read 1 to \temp
  1748.     \ifeof 1
  1749.       (Index is empty)
  1750.     \else
  1751.       \input \jobname.#1s
  1752.     \fi
  1753.   \fi
  1754.   \closein 1
  1755.   \enddoublecolumns
  1756.   \Etex
  1757. }
  1758.  
  1759. % These macros are used by the sorted index file itself.
  1760. % Change them to control the appearance of the index.
  1761.  
  1762. % Same as \bigskipamount except no shrink.
  1763. % \balancecolumns gets confused if there is any shrink.
  1764. \newskip\initialskipamount \initialskipamount 12pt plus4pt
  1765.  
  1766. \def\initial #1{%
  1767. {\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
  1768. \ifdim\lastskip<\initialskipamount
  1769. \removelastskip \penalty-200 \vskip \initialskipamount\fi
  1770. \line{\secbf#1\hfill}\kern 2pt\penalty10000}}
  1771.  
  1772. % This typesets a paragraph consisting of #1, dot leaders, and then #2
  1773. % flush to the right margin.  It is used for index and table of contents
  1774. % entries.  The paragraph is indented by \leftskip.
  1775. \def\entry #1#2{\begingroup
  1776.   %
  1777.   % Start a new paragraph if necessary, so our assignments below can't
  1778.   % affect previous text.
  1779.   \par
  1780.   %
  1781.   % Do not fill out the last line with white space.
  1782.   \parfillskip = 0in
  1783.   %
  1784.   % No extra space above this paragraph.
  1785.   \parskip = 0in
  1786.   %
  1787.   % Do not prefer a separate line ending with a hyphen to fewer lines.
  1788.   \finalhyphendemerits = 0
  1789.   %
  1790.   % \hangindent is only relevant when the entry text and page number
  1791.   % don't both fit on one line.  In that case, bob suggests starting the
  1792.   % dots pretty far over on the line.  Unfortunately, a large
  1793.   % indentation looks wrong when the entry text itself is broken across
  1794.   % lines.  So we use a small indentation and put up with long leaders.
  1795.   % 
  1796.   % \hangafter is reset to 1 (which is the value we want) at the start
  1797.   % of each paragraph, so we need not do anything with that.
  1798.   \hangindent=2em
  1799.   %
  1800.   % When the entry text needs to be broken, just fill out the first line
  1801.   % with blank space.
  1802.   \rightskip = 0pt plus1fil
  1803.   %
  1804.   % Start a ``paragraph'' for the index entry so the line breaking
  1805.   % parameters we've set above will have an effect.
  1806.   \noindent
  1807.   %
  1808.   % Insert the text of the index entry.  TeX will do line-breaking on it.
  1809.   #1%
  1810.   %
  1811.   % If we must, put the page number on a line of its own, and fill out
  1812.   % this line with blank space.  (The \hfil is overwhelmed with the
  1813.   % fill leaders glue in \indexdotfill if the page number does fit.)
  1814.   \hfil\penalty50
  1815.   \null\nobreak\indexdotfill % Have leaders before the page number.
  1816.   %
  1817.   % The `\ ' here is removed by the implicit \unskip that TeX does as
  1818.   % part of (the primitive) \par.  Without it, a spurious underfull
  1819.   % \hbox ensues.
  1820.   \ #2% The page number ends the paragraph.
  1821.   \par
  1822. \endgroup}
  1823.  
  1824. % Like \dotfill except takes at least 1 em.
  1825. \def\indexdotfill{\cleaders
  1826.   \hbox{$\mathsurround=0pt \mkern1.5mu . \mkern1.5mu$}\hskip 1em plus 1fill}
  1827.  
  1828. \def\primary #1{\line{#1\hfil}}
  1829.  
  1830. \newskip\secondaryindent \secondaryindent=0.5cm
  1831.  
  1832. \def\secondary #1#2{
  1833. {\parfillskip=0in \parskip=0in
  1834. \hangindent =1in \hangafter=1
  1835. \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
  1836. }}
  1837.  
  1838. %% Define two-column mode, which is used in indexes.
  1839. %% Adapted from the TeXbook, page 416.
  1840. \catcode `\@=11
  1841.  
  1842. \newbox\partialpage
  1843.  
  1844. \newdimen\doublecolumnhsize
  1845.  
  1846. \def\begindoublecolumns{\begingroup
  1847.   % Grab any single-column material above us.
  1848.   \output = {\global\setbox\partialpage
  1849.     =\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}%
  1850.   \eject
  1851.   %
  1852.   % Now switch to the double-column output routine.
  1853.   \output={\doublecolumnout}%
  1854.   %
  1855.   % Change the page size parameters.  We could do this once outside this
  1856.   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
  1857.   % format, but then we repeat the same computation.  Repeating a couple
  1858.   % of assignments once per index is clearly meaningless for the
  1859.   % execution time, so we may as well do it once.
  1860.   % 
  1861.   % First we halve the line length, less a little for the gutter between
  1862.   % the columns.  We compute the gutter based on the line length, so it
  1863.   % changes automatically with the paper format.  The magic constant
  1864.   % below is chosen so that the gutter has the same value (well, +- <
  1865.   % 1pt) as it did when we hard-coded it.
  1866.   % 
  1867.   % We put the result in a separate register, \doublecolumhsize, so we
  1868.   % can restore it in \pagesofar, after \hsize itself has (potentially)
  1869.   % been clobbered.
  1870.   % 
  1871.   \doublecolumnhsize = \hsize
  1872.     \advance\doublecolumnhsize by -.04154\hsize
  1873.     \divide\doublecolumnhsize by 2
  1874.   \hsize = \doublecolumnhsize
  1875.   %
  1876.   % Double the \vsize as well.  (We don't need a separate register here,
  1877.   % since nobody clobbers \vsize.)
  1878.   \vsize = 2\vsize
  1879.   \doublecolumnpagegoal
  1880. }
  1881.  
  1882. \def\enddoublecolumns{\eject \endgroup \pagegoal=\vsize \unvbox\partialpage}
  1883.  
  1884. \def\doublecolumnsplit{\splittopskip=\topskip \splitmaxdepth=\maxdepth
  1885.   \global\dimen@=\pageheight \global\advance\dimen@ by-\ht\partialpage
  1886.   \global\setbox1=\vsplit255 to\dimen@ \global\setbox0=\vbox{\unvbox1}
  1887.   \global\setbox3=\vsplit255 to\dimen@ \global\setbox2=\vbox{\unvbox3}
  1888.   \ifdim\ht0>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi
  1889.   \ifdim\ht2>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi
  1890. }
  1891. \def\doublecolumnpagegoal{%
  1892.   \dimen@=\vsize \advance\dimen@ by-2\ht\partialpage \global\pagegoal=\dimen@
  1893. }
  1894. \def\pagesofar{\unvbox\partialpage %
  1895.   \hsize=\doublecolumnhsize % have to restore this since output routine
  1896.   \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}}
  1897. \def\doublecolumnout{%
  1898.   \setbox5=\copy255
  1899.   {\vbadness=10000 \doublecolumnsplit}
  1900.   \ifvbox255
  1901.     \setbox0=\vtop to\dimen@{\unvbox0}
  1902.     \setbox2=\vtop to\dimen@{\unvbox2}
  1903.     \onepageout\pagesofar \unvbox255 \penalty\outputpenalty
  1904.   \else
  1905.     \setbox0=\vbox{\unvbox5}
  1906.     \ifvbox0
  1907.       \dimen@=\ht0 \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  1908.       \divide\dimen@ by2 \splittopskip=\topskip \splitmaxdepth=\maxdepth
  1909.       {\vbadness=10000
  1910.     \loop \global\setbox5=\copy0
  1911.           \setbox1=\vsplit5 to\dimen@
  1912.           \setbox3=\vsplit5 to\dimen@
  1913.           \ifvbox5 \global\advance\dimen@ by1pt \repeat
  1914.         \setbox0=\vbox to\dimen@{\unvbox1}
  1915.         \setbox2=\vbox to\dimen@{\unvbox3}
  1916.         \global\setbox\partialpage=\vbox{\pagesofar}
  1917.         \doublecolumnpagegoal
  1918.       }
  1919.     \fi
  1920.   \fi
  1921. }
  1922.  
  1923. \catcode `\@=\other
  1924. \message{sectioning,}
  1925. % Define chapters, sections, etc.
  1926.  
  1927. \newcount \chapno
  1928. \newcount \secno        \secno=0
  1929. \newcount \subsecno     \subsecno=0
  1930. \newcount \subsubsecno  \subsubsecno=0
  1931.  
  1932. % This counter is funny since it counts through charcodes of letters A, B, ...
  1933. \newcount \appendixno  \appendixno = `\@
  1934. \def\appendixletter{\char\the\appendixno}
  1935.  
  1936. \newwrite \contentsfile
  1937. % This is called from \setfilename.
  1938. \def\opencontents{\openout \contentsfile = \jobname.toc}
  1939.  
  1940. % Each @chapter defines this as the name of the chapter.
  1941. % page headings and footings can use it.  @section does likewise
  1942.  
  1943. \def\thischapter{} \def\thissection{}
  1944. \def\seccheck#1{\if \pageno<0 %
  1945. \errmessage{@#1 not allowed after generating table of contents}\fi
  1946. %
  1947. }
  1948.  
  1949. \def\chapternofonts{%
  1950. \let\rawbackslash=\relax%
  1951. \let\frenchspacing=\relax%
  1952. \def\result{\realbackslash result}
  1953. \def\equiv{\realbackslash equiv}
  1954. \def\expansion{\realbackslash expansion}
  1955. \def\print{\realbackslash print}
  1956. \def\TeX{\realbackslash TeX}
  1957. \def\dots{\realbackslash dots}
  1958. \def\copyright{\realbackslash copyright}
  1959. \def\tt{\realbackslash tt}
  1960. \def\bf{\realbackslash bf }
  1961. \def\w{\realbackslash w}
  1962. \def\less{\realbackslash less}
  1963. \def\gtr{\realbackslash gtr}
  1964. \def\hat{\realbackslash hat}
  1965. \def\char{\realbackslash char}
  1966. \def\tclose##1{\realbackslash tclose {##1}}
  1967. \def\code##1{\realbackslash code {##1}}
  1968. \def\samp##1{\realbackslash samp {##1}}
  1969. \def\r##1{\realbackslash r {##1}}
  1970. \def\b##1{\realbackslash b {##1}}
  1971. \def\key##1{\realbackslash key {##1}}
  1972. \def\file##1{\realbackslash file {##1}}
  1973. \def\kbd##1{\realbackslash kbd {##1}}
  1974. % These are redefined because @smartitalic wouldn't work inside xdef.
  1975. \def\i##1{\realbackslash i {##1}}
  1976. \def\cite##1{\realbackslash cite {##1}}
  1977. \def\var##1{\realbackslash var {##1}}
  1978. \def\emph##1{\realbackslash emph {##1}}
  1979. \def\dfn##1{\realbackslash dfn {##1}}
  1980. }
  1981.  
  1982. \def\thischaptername{No Chapter Title}
  1983. \outer\def\chapter{\parsearg\chapterzzz}
  1984. \def\chapterzzz #1{\seccheck{chapter}%
  1985. \secno=0 \subsecno=0 \subsubsecno=0
  1986. \global\advance \chapno by 1 \message{Chapter \the\chapno}%
  1987. \chapmacro {#1}{\the\chapno}%
  1988. \gdef\thissection{#1}%
  1989. \gdef\thischaptername{#1}%
  1990. % We don't substitute the actual chapter name into \thischapter
  1991. % because we don't want its macros evaluated now.
  1992. \xdef\thischapter{Chapter \the\chapno: \noexpand\thischaptername}%
  1993. {\chapternofonts%
  1994. \edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}%
  1995. \escapechar=`\\%
  1996. \write \contentsfile \temp  %
  1997. \donoderef %
  1998. \global\let\section = \numberedsec
  1999. \global\let\subsection = \numberedsubsec
  2000. \global\let\subsubsection = \numberedsubsubsec
  2001. }}
  2002.  
  2003. \outer\def\appendix{\parsearg\appendixzzz}
  2004. \def\appendixzzz #1{\seccheck{appendix}%
  2005. \secno=0 \subsecno=0 \subsubsecno=0
  2006. \global\advance \appendixno by 1 \message{Appendix \appendixletter}%
  2007. \chapmacro {#1}{Appendix \appendixletter}%
  2008. \gdef\thissection{#1}%
  2009. \gdef\thischaptername{#1}%
  2010. \xdef\thischapter{Appendix \appendixletter: \noexpand\thischaptername}%
  2011. {\chapternofonts%
  2012. \edef\temp{{\realbackslash chapentry 
  2013.   {#1}{Appendix \appendixletter}{\noexpand\folio}}}%
  2014. \escapechar=`\\%
  2015. \write \contentsfile \temp  %
  2016. \appendixnoderef %
  2017. \global\let\section = \appendixsec
  2018. \global\let\subsection = \appendixsubsec
  2019. \global\let\subsubsection = \appendixsubsubsec
  2020. }}
  2021.  
  2022. \outer\def\top{\parsearg\unnumberedzzz}
  2023. \outer\def\unnumbered{\parsearg\unnumberedzzz}
  2024. \def\unnumberedzzz #1{\seccheck{unnumbered}%
  2025. \secno=0 \subsecno=0 \subsubsecno=0
  2026. %
  2027. % This used to be simply \message{#1}, but TeX fully expands the
  2028. % argument to \message.  Therefore, if #1 contained @-commands, TeX
  2029. % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
  2030. % expanded @cite (which turns out to cause errors because \cite is meant
  2031. % to be executed, not expanded).  
  2032. % Anyway, we don't want the fully-expanded definition of @cite to appear
  2033. % as a result of the \message, we just want `@cite' itself.  We use
  2034. % \the<toks register> to achieve this: TeX expands \the<toks> only once,
  2035. % simply yielding the contents of the <toks register>.
  2036. \toks0 = {#1}\message{(\the\toks0)}%
  2037. %
  2038. \unnumbchapmacro {#1}%
  2039. \gdef\thischapter{#1}\gdef\thissection{#1}%
  2040. {\chapternofonts%
  2041. \edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}%
  2042. \escapechar=`\\%
  2043. \write \contentsfile \temp  %
  2044. \unnumbnoderef %
  2045. \global\let\section = \unnumberedsec
  2046. \global\let\subsection = \unnumberedsubsec
  2047. \global\let\subsubsection = \unnumberedsubsubsec
  2048. }}
  2049.  
  2050. \outer\def\numberedsec{\parsearg\seczzz}
  2051. \def\seczzz #1{\seccheck{section}%
  2052. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  2053. \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
  2054. {\chapternofonts%
  2055. \edef\temp{{\realbackslash secentry %
  2056. {#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}%
  2057. \escapechar=`\\%
  2058. \write \contentsfile \temp %
  2059. \donoderef %
  2060. \penalty 10000 %
  2061. }}
  2062.  
  2063. \outer\def\appendixsection{\parsearg\appendixsectionzzz}
  2064. \outer\def\appendixsec{\parsearg\appendixsectionzzz}
  2065. \def\appendixsectionzzz #1{\seccheck{appendixsection}%
  2066. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  2067. \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
  2068. {\chapternofonts%
  2069. \edef\temp{{\realbackslash secentry %
  2070. {#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}%
  2071. \escapechar=`\\%
  2072. \write \contentsfile \temp %
  2073. \appendixnoderef %
  2074. \penalty 10000 %
  2075. }}
  2076.  
  2077. \outer\def\unnumberedsec{\parsearg\unnumberedseczzz}
  2078. \def\unnumberedseczzz #1{\seccheck{unnumberedsec}%
  2079. \plainsecheading {#1}\gdef\thissection{#1}%
  2080. {\chapternofonts%
  2081. \edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}%
  2082. \escapechar=`\\%
  2083. \write \contentsfile \temp %
  2084. \unnumbnoderef %
  2085. \penalty 10000 %
  2086. }}
  2087.  
  2088. \outer\def\numberedsubsec{\parsearg\numberedsubseczzz}
  2089. \def\numberedsubseczzz #1{\seccheck{subsection}%
  2090. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  2091. \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
  2092. {\chapternofonts%
  2093. \edef\temp{{\realbackslash subsecentry %
  2094. {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  2095. \escapechar=`\\%
  2096. \write \contentsfile \temp %
  2097. \donoderef %
  2098. \penalty 10000 %
  2099. }}
  2100.  
  2101. \outer\def\appendixsubsec{\parsearg\appendixsubseczzz}
  2102. \def\appendixsubseczzz #1{\seccheck{appendixsubsec}%
  2103. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  2104. \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
  2105. {\chapternofonts%
  2106. \edef\temp{{\realbackslash subsecentry %
  2107. {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  2108. \escapechar=`\\%
  2109. \write \contentsfile \temp %
  2110. \appendixnoderef %
  2111. \penalty 10000 %
  2112. }}
  2113.  
  2114. \outer\def\unnumberedsubsec{\parsearg\unnumberedsubseczzz}
  2115. \def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}%
  2116. \plainsecheading {#1}\gdef\thissection{#1}%
  2117. {\chapternofonts%
  2118. \edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}%
  2119. \escapechar=`\\%
  2120. \write \contentsfile \temp %
  2121. \unnumbnoderef %
  2122. \penalty 10000 %
  2123. }}
  2124.  
  2125. \outer\def\numberedsubsubsec{\parsearg\numberedsubsubseczzz}
  2126. \def\numberedsubsubseczzz #1{\seccheck{subsubsection}%
  2127. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  2128. \subsubsecheading {#1}
  2129.   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  2130. {\chapternofonts%
  2131. \edef\temp{{\realbackslash subsubsecentry %
  2132.   {#1}
  2133.   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}
  2134.   {\noexpand\folio}}}%
  2135. \escapechar=`\\%
  2136. \write \contentsfile \temp %
  2137. \donoderef %
  2138. \penalty 10000 %
  2139. }}
  2140.  
  2141. \outer\def\appendixsubsubsec{\parsearg\appendixsubsubseczzz}
  2142. \def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}%
  2143. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  2144. \subsubsecheading {#1}
  2145.   {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  2146. {\chapternofonts%
  2147. \edef\temp{{\realbackslash subsubsecentry{#1}%
  2148.   {\appendixletter}
  2149.   {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%
  2150. \escapechar=`\\%
  2151. \write \contentsfile \temp %
  2152. \appendixnoderef %
  2153. \penalty 10000 %
  2154. }}
  2155.  
  2156. \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  2157. \def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}%
  2158. \plainsecheading {#1}\gdef\thissection{#1}%
  2159. {\chapternofonts%
  2160. \edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}%
  2161. \escapechar=`\\%
  2162. \write \contentsfile \temp %
  2163. \unnumbnoderef %
  2164. \penalty 10000 %
  2165. }}
  2166.  
  2167. % These are variants which are not "outer", so they can appear in @ifinfo.
  2168. % Actually, they should now be obsolete; ordinary section commands should work.
  2169. \def\infotop{\parsearg\unnumberedzzz}
  2170. \def\infounnumbered{\parsearg\unnumberedzzz}
  2171. \def\infounnumberedsec{\parsearg\unnumberedseczzz}
  2172. \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
  2173. \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  2174.  
  2175. \def\infoappendix{\parsearg\appendixzzz}
  2176. \def\infoappendixsec{\parsearg\appendixseczzz}
  2177. \def\infoappendixsubsec{\parsearg\appendixsubseczzz}
  2178. \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
  2179.  
  2180. \def\infochapter{\parsearg\chapterzzz}
  2181. \def\infosection{\parsearg\sectionzzz}
  2182. \def\infosubsection{\parsearg\subsectionzzz}
  2183. \def\infosubsubsection{\parsearg\subsubsectionzzz}
  2184.  
  2185. % These macros control what the section commands do, according
  2186. % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
  2187. % Define them by default for a numbered chapter.
  2188. \global\let\section = \numberedsec
  2189. \global\let\subsection = \numberedsubsec
  2190. \global\let\subsubsection = \numberedsubsubsec
  2191.  
  2192. % Define @majorheading, @heading and @subheading
  2193.  
  2194. % NOTE on use of \vbox for chapter headings, section headings, and
  2195. % such:
  2196. %    1) We use \vbox rather than the earlier \line to permit
  2197. %       overlong headings to fold.
  2198. %    2) \hyphenpenalty is set to 10000 because hyphenation in a
  2199. %       heading is obnoxious; this forbids it.
  2200. %       3) Likewise, headings look best if no \parindent is used, and
  2201. %          if justification is not attempted.  Hence \raggedright.
  2202.  
  2203.  
  2204. \def\majorheading{\parsearg\majorheadingzzz}
  2205. \def\majorheadingzzz #1{%
  2206. {\advance\chapheadingskip by 10pt \chapbreak }%
  2207. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2208.                   \parindent=0pt\raggedright
  2209.                   \rm #1\hfill}}\bigskip \par\penalty 200}
  2210.  
  2211. \def\chapheading{\parsearg\chapheadingzzz}
  2212. \def\chapheadingzzz #1{\chapbreak %
  2213. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2214.                   \parindent=0pt\raggedright
  2215.                   \rm #1\hfill}}\bigskip \par\penalty 200}
  2216.  
  2217. \def\heading{\parsearg\secheadingi}
  2218.  
  2219. \def\subheading{\parsearg\subsecheadingi}
  2220.  
  2221. \def\subsubheading{\parsearg\subsubsecheadingi}
  2222.  
  2223. % These macros generate a chapter, section, etc. heading only
  2224. % (including whitespace, linebreaking, etc. around it),
  2225. % given all the information in convenient, parsed form.
  2226.  
  2227. %%% Args are the skip and penalty (usually negative)
  2228. \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
  2229.  
  2230. \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
  2231.  
  2232. %%% Define plain chapter starts, and page on/off switching for it
  2233. % Parameter controlling skip before chapter headings (if needed)
  2234.  
  2235. \newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt
  2236.  
  2237. \def\chapbreak{\dobreak \chapheadingskip {-4000}}
  2238. \def\chappager{\par\vfill\supereject}
  2239. \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
  2240.  
  2241. \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
  2242.  
  2243. \def\CHAPPAGoff{
  2244. \global\let\pchapsepmacro=\chapbreak
  2245. \global\let\pagealignmacro=\chappager}
  2246.  
  2247. \def\CHAPPAGon{
  2248. \global\let\pchapsepmacro=\chappager
  2249. \global\let\pagealignmacro=\chappager
  2250. \global\def\HEADINGSon{\HEADINGSsingle}}
  2251.  
  2252. \def\CHAPPAGodd{
  2253. \global\let\pchapsepmacro=\chapoddpage
  2254. \global\let\pagealignmacro=\chapoddpage
  2255. \global\def\HEADINGSon{\HEADINGSdouble}}
  2256.  
  2257. \CHAPPAGon
  2258.  
  2259. \def\CHAPFplain{
  2260. \global\let\chapmacro=\chfplain
  2261. \global\let\unnumbchapmacro=\unnchfplain}
  2262.  
  2263. \def\chfplain #1#2{%
  2264.   \pchapsepmacro
  2265.   {%
  2266.     \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2267.                      \parindent=0pt\raggedright
  2268.                      \rm #2\enspace #1}%
  2269.   }%
  2270.   \bigskip
  2271.   \penalty5000
  2272. }
  2273.  
  2274. \def\unnchfplain #1{%
  2275. \pchapsepmacro %
  2276. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2277.                   \parindent=0pt\raggedright
  2278.                   \rm #1\hfill}}\bigskip \par\penalty 10000 %
  2279. }
  2280. \CHAPFplain % The default
  2281.  
  2282. \def\unnchfopen #1{%
  2283. \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2284.                        \parindent=0pt\raggedright
  2285.                        \rm #1\hfill}}\bigskip \par\penalty 10000 %
  2286. }
  2287.  
  2288. \def\chfopen #1#2{\chapoddpage {\chapfonts
  2289. \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
  2290. \par\penalty 5000 %
  2291. }
  2292.  
  2293. \def\CHAPFopen{
  2294. \global\let\chapmacro=\chfopen
  2295. \global\let\unnumbchapmacro=\unnchfopen}
  2296.  
  2297. % Parameter controlling skip before section headings.
  2298.  
  2299. \newskip \subsecheadingskip  \subsecheadingskip = 17pt plus 8pt minus 4pt
  2300. \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
  2301.  
  2302. \newskip \secheadingskip  \secheadingskip = 21pt plus 8pt minus 4pt
  2303. \def\secheadingbreak{\dobreak \secheadingskip {-1000}}
  2304.  
  2305. % @paragraphindent  is defined for the Info formatting commands only.
  2306. \let\paragraphindent=\comment
  2307.  
  2308. % Section fonts are the base font at magstep2, which produces
  2309. % a size a bit more than 14 points in the default situation.    
  2310.  
  2311. \def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}}
  2312. \def\plainsecheading #1{\secheadingi {#1}}
  2313. \def\secheadingi #1{{\advance \secheadingskip by \parskip %
  2314. \secheadingbreak}%
  2315. {\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2316.                  \parindent=0pt\raggedright
  2317.                  \rm #1\hfill}}%
  2318. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  2319.  
  2320.  
  2321. % Subsection fonts are the base font at magstep1, 
  2322. % which produces a size of 12 points.
  2323.  
  2324. \def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}}
  2325. \def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip %
  2326. \subsecheadingbreak}%
  2327. {\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2328.                      \parindent=0pt\raggedright
  2329.                      \rm #1\hfill}}%
  2330. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  2331.  
  2332. \def\subsubsecfonts{\subsecfonts} % Maybe this should change:
  2333.                   % Perhaps make sssec fonts scaled
  2334.                   % magstep half
  2335. \def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}}
  2336. \def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip %
  2337. \subsecheadingbreak}%
  2338. {\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2339.                        \parindent=0pt\raggedright
  2340.                        \rm #1\hfill}}%
  2341. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000}
  2342.  
  2343.  
  2344. \message{toc printing,}
  2345.  
  2346. % Finish up the main text and prepare to read what we've written
  2347. % to \contentsfile.
  2348.  
  2349. \newskip\contentsrightmargin \contentsrightmargin=1in
  2350. \def\startcontents#1{%
  2351.    \pagealignmacro
  2352.    \immediate\closeout \contentsfile
  2353.    \ifnum \pageno>0
  2354.       \pageno = -1        % Request roman numbered pages.
  2355.    \fi
  2356.    % Don't need to put `Contents' or `Short Contents' in the headline. 
  2357.    % It is abundantly clear what they are.
  2358.    \unnumbchapmacro{#1}\def\thischapter{}%
  2359.    \begingroup           % Set up to handle contents files properly.
  2360.       \catcode`\\=0  \catcode`\{=1  \catcode`\}=2  \catcode`\@=11
  2361.       \raggedbottom             % Worry more about breakpoints than the bottom.
  2362.       \advance\hsize by -\contentsrightmargin % Don't use the full line length.
  2363. }
  2364.  
  2365.   
  2366. % Normal (long) toc.
  2367. \outer\def\contents{%
  2368.    \startcontents{Table of Contents}%
  2369.       \input \jobname.toc
  2370.    \endgroup
  2371.    \vfill \eject
  2372. }
  2373.  
  2374. % And just the chapters.
  2375. \outer\def\summarycontents{%
  2376.    \startcontents{Short Contents}%
  2377.       %
  2378.       \let\chapentry = \shortchapentry
  2379.       \let\unnumbchapentry = \shortunnumberedentry
  2380.       % We want a true roman here for the page numbers.
  2381.       \secfonts
  2382.       \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
  2383.       \rm
  2384.       \advance\baselineskip by 1pt % Open it up a little.
  2385.       \def\secentry ##1##2##3##4{}
  2386.       \def\unnumbsecentry ##1##2{}
  2387.       \def\subsecentry ##1##2##3##4##5{}
  2388.       \def\unnumbsubsecentry ##1##2{}
  2389.       \def\subsubsecentry ##1##2##3##4##5##6{}
  2390.       \def\unnumbsubsubsecentry ##1##2{}
  2391.       \input \jobname.toc
  2392.    \endgroup
  2393.    \vfill \eject
  2394. }
  2395. \let\shortcontents = \summarycontents
  2396.  
  2397. % These macros generate individual entries in the table of contents.
  2398. % The first argument is the chapter or section name.
  2399. % The last argument is the page number.
  2400. % The arguments in between are the chapter number, section number, ...
  2401.  
  2402. % Chapter-level things, for both the long and short contents.
  2403. \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
  2404.  
  2405. % See comments in \dochapentry re vbox and related settings
  2406. \def\shortchapentry#1#2#3{%
  2407.   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}%
  2408. }
  2409.  
  2410. % Typeset the label for a chapter or appendix for the short contents.
  2411. % The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter.
  2412. % We could simplify the code here by writing out an \appendixentry
  2413. % command in the toc file for appendices, instead of using \chapentry
  2414. % for both, but it doesn't seem worth it.
  2415. \setbox0 = \hbox{\shortcontrm Appendix }
  2416. \newdimen\shortappendixwidth \shortappendixwidth = \wd0
  2417.  
  2418. \def\shortchaplabel#1{%
  2419.   % We typeset #1 in a box of constant width, regardless of the text of
  2420.   % #1, so the chapter titles will come out aligned.
  2421.   \setbox0 = \hbox{#1}%
  2422.   \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi
  2423.   %
  2424.   % This space should be plenty, since a single number is .5em, and the
  2425.   % widest letter (M) is 1em, at least in the Computer Modern fonts.
  2426.   % (This space doesn't include the extra space that gets added after
  2427.   % the label; that gets put in in \shortchapentry above.)
  2428.   \advance\dimen0 by 1.1em
  2429.   \hbox to \dimen0{#1\hfil}%
  2430. }
  2431.  
  2432. \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
  2433. \def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}}
  2434.  
  2435. % Sections.
  2436. \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
  2437. \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
  2438.  
  2439. % Subsections.
  2440. \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
  2441. \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
  2442.  
  2443. % And subsubsections.
  2444. \def\subsubsecentry#1#2#3#4#5#6{%
  2445.   \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
  2446. \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
  2447.  
  2448.  
  2449. % This parameter controls the indentation of the various levels.
  2450. \newdimen\tocindent \tocindent = 3pc
  2451.  
  2452. % Now for the actual typesetting. In all these, #1 is the text and #2 is the 
  2453. % page number.
  2454. %
  2455. % If the toc has to be broken over pages, we would want to be at chapters 
  2456. % if at all possible; hence the \penalty.
  2457. \def\dochapentry#1#2{%
  2458.    \penalty-300 \vskip\baselineskip
  2459.    \begingroup
  2460.      \chapentryfonts
  2461.      \tocentry{#1}{\dopageno{#2}}%
  2462.    \endgroup
  2463.    \nobreak\vskip .25\baselineskip
  2464. }
  2465.  
  2466. \def\dosecentry#1#2{\begingroup
  2467.   \secentryfonts \leftskip=\tocindent
  2468.   \tocentry{#1}{\dopageno{#2}}%
  2469. \endgroup}
  2470.  
  2471. \def\dosubsecentry#1#2{\begingroup
  2472.   \subsecentryfonts \leftskip=2\tocindent
  2473.   \tocentry{#1}{\dopageno{#2}}%
  2474. \endgroup}
  2475.  
  2476. \def\dosubsubsecentry#1#2{\begingroup
  2477.   \subsubsecentryfonts \leftskip=3\tocindent
  2478.   \tocentry{#1}{\dopageno{#2}}%
  2479. \endgroup}
  2480.  
  2481. % Final typesetting of a toc entry; we use the same \entry macro as for
  2482. % the index entries, but we want to suppress hyphenation here.  (We
  2483. % can't do that in the \entry macro, since index entries might consist
  2484. % of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.)
  2485. \def\tocentry#1#2{\begingroup
  2486.   \hyphenpenalty = 10000
  2487.   \entry{#1}{#2}%
  2488. \endgroup}
  2489.  
  2490. % Space between chapter (or whatever) number and the title.
  2491. \def\labelspace{\hskip1em \relax}
  2492.  
  2493. \def\dopageno#1{{\rm #1}}
  2494. \def\doshortpageno#1{{\rm #1}}
  2495.  
  2496. \def\chapentryfonts{\secfonts \rm}
  2497. \def\secentryfonts{\textfonts}
  2498. \let\subsecentryfonts = \textfonts
  2499. \let\subsubsecentryfonts = \textfonts
  2500.  
  2501.  
  2502. \message{environments,}
  2503.  
  2504. % Since these characters are used in examples, it should be an even number of 
  2505. % \tt widths. Each \tt character is 1en, so two makes it 1em.
  2506. % Furthermore, these definitions must come after we define our fonts.
  2507. \newbox\dblarrowbox    \newbox\longdblarrowbox
  2508. \newbox\pushcharbox    \newbox\bullbox
  2509. \newbox\equivbox       \newbox\errorbox
  2510.  
  2511. \let\ptexequiv = \equiv
  2512.  
  2513. %{\tentt
  2514. %\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
  2515. %\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
  2516. %\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
  2517. %\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
  2518. % Adapted from the manmac format (p.420 of TeXbook)
  2519. %\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
  2520. %                                      depth .1ex\hfil}
  2521. %}
  2522.  
  2523. \def\point{$\star$}
  2524.  
  2525. \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
  2526. \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
  2527. \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
  2528.  
  2529. \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
  2530.  
  2531. % Adapted from the TeXbook's \boxit.
  2532. {\tentt \global\dimen0 = 3em}% Width of the box.
  2533. \dimen2 = .55pt % Thickness of rules
  2534. % The text. (`r' is open on the right, `e' somewhat less so on the left.)
  2535. \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
  2536.  
  2537. \global\setbox\errorbox=\hbox to \dimen0{\hfil
  2538.    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
  2539.    \advance\hsize by -2\dimen2 % Rules.
  2540.    \vbox{
  2541.       \hrule height\dimen2
  2542.       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
  2543.          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
  2544.          \kern3pt\vrule width\dimen2}% Space to right.
  2545.       \hrule height\dimen2}
  2546.     \hfil}
  2547.  
  2548. % The @error{} command.
  2549. \def\error{\leavevmode\lower.7ex\copy\errorbox}
  2550.  
  2551. % @tex ... @end tex    escapes into raw Tex temporarily.
  2552. % One exception: @ is still an escape character, so that @end tex works.
  2553. % But \@ or @@ will get a plain tex @ character.
  2554.  
  2555. \def\tex{\begingroup
  2556. \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
  2557. \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
  2558. \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
  2559. \catcode `\%=14
  2560. \catcode 43=12
  2561. \catcode`\"=12
  2562. \catcode`\==12
  2563. \catcode`\|=12
  2564. \catcode`\<=12
  2565. \catcode`\>=12
  2566. \escapechar=`\\
  2567. %
  2568. \let\{=\ptexlbrace
  2569. \let\}=\ptexrbrace
  2570. \let\.=\ptexdot
  2571. \let\*=\ptexstar
  2572. \let\dots=\ptexdots
  2573. \def\@{@}%
  2574. \let\bullet=\ptexbullet
  2575. \let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl
  2576. \let\L=\ptexL
  2577. %
  2578. \let\Etex=\endgroup}
  2579.  
  2580. % Define @lisp ... @endlisp.
  2581. % @lisp does a \begingroup so it can rebind things,
  2582. % including the definition of @endlisp (which normally is erroneous).
  2583.  
  2584. % Amount to narrow the margins by for @lisp.
  2585. \newskip\lispnarrowing \lispnarrowing=0.4in
  2586.  
  2587. % This is the definition that ^M gets inside @lisp
  2588. % phr: changed space to \null, to avoid overfull hbox problems.
  2589. {\obeyspaces%
  2590. \gdef\lisppar{\null\endgraf}}
  2591.  
  2592. % Cause \obeyspaces to make each Space cause a word-separation
  2593. % rather than the default which is that it acts punctuation.
  2594. % This is because space in tt font looks funny.
  2595. {\obeyspaces %
  2596. \gdef\sepspaces{\def {\ }}}
  2597.  
  2598. % This space is always present above and below environments.
  2599. \newskip\envskipamount \envskipamount = 0pt
  2600.  
  2601. % Make spacing and below environment symmetrical.
  2602. \def\aboveenvbreak{{\advance\envskipamount by \parskip
  2603. \endgraf \ifdim\lastskip<\envskipamount
  2604. \removelastskip \penalty-50 \vskip\envskipamount \fi}}
  2605.  
  2606. \let\afterenvbreak = \aboveenvbreak
  2607.  
  2608. % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins.
  2609. \let\nonarrowing=\relax
  2610.  
  2611. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2612. % \cartouche: draw rectangle w/rounded corners around argument
  2613. \font\circle=lcircle10
  2614. \newdimen\circthick
  2615. \newdimen\cartouter\newdimen\cartinner
  2616. \newskip\normbskip\newskip\normpskip\newskip\normlskip
  2617. \circthick=\fontdimen8\circle
  2618. %
  2619. \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
  2620. \def\ctr{{\hskip 6pt\circle\char'010}}
  2621. \def\cbl{{\circle\char'012\hskip -6pt}}
  2622. \def\cbr{{\hskip 6pt\circle\char'011}}
  2623. \def\carttop{\hbox to \cartouter{\hskip\lskip
  2624.     \ctl\leaders\hrule height\circthick\hfil\ctr
  2625.     \hskip\rskip}}
  2626. \def\cartbot{\hbox to \cartouter{\hskip\lskip
  2627.     \cbl\leaders\hrule height\circthick\hfil\cbr
  2628.     \hskip\rskip}}
  2629. %
  2630. \newskip\lskip\newskip\rskip
  2631.  
  2632. \long\def\cartouche{%
  2633. \begingroup
  2634.     \lskip=\leftskip \rskip=\rightskip
  2635.     \leftskip=0pt\rightskip=0pt %we want these *outside*.
  2636.     \cartinner=\hsize \advance\cartinner by-\lskip 
  2637.                \advance\cartinner by-\rskip
  2638.     \cartouter=\hsize
  2639.     \advance\cartouter by 18pt % allow for 3pt kerns on either
  2640. %                     side, and for 6pt waste from
  2641. %                     each corner char
  2642.     \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
  2643.     % Flag to tell @lisp, etc., not to narrow margin.
  2644.     \let\nonarrowing=\comment
  2645.     \vbox\bgroup
  2646.         \baselineskip=0pt\parskip=0pt\lineskip=0pt
  2647.         \carttop
  2648.         \hbox\bgroup
  2649.             \hskip\lskip
  2650.             \vrule\kern3pt
  2651.             \vbox\bgroup
  2652.                 \hsize=\cartinner
  2653.                 \kern3pt
  2654.                 \begingroup
  2655.                     \baselineskip=\normbskip
  2656.                     \lineskip=\normlskip
  2657.                     \parskip=\normpskip
  2658.                     \vskip -\parskip
  2659. \def\Ecartouche{%
  2660.                 \endgroup
  2661.                 \kern3pt
  2662.             \egroup
  2663.             \kern3pt\vrule
  2664.             \hskip\rskip
  2665.         \egroup
  2666.         \cartbot
  2667.     \egroup
  2668. \endgroup
  2669. }}    
  2670.  
  2671. \def\lisp{\aboveenvbreak
  2672. \begingroup\inENV % This group ends at the end of the @lisp body
  2673. \hfuzz=12truept % Don't be fussy
  2674. % Make spaces be word-separators rather than space tokens.
  2675. \sepspaces %
  2676. % Single space lines
  2677. \singlespace %
  2678. % The following causes blank lines not to be ignored
  2679. % by adding a space to the end of each line.
  2680. \let\par=\lisppar
  2681. \def\Elisp{\endgroup\afterenvbreak}%
  2682. \parskip=0pt
  2683. % @cartouche defines \nonarrowing to inhibit narrowing
  2684. % at next level down.
  2685. \ifx\nonarrowing\relax
  2686. \advance \leftskip by \lispnarrowing
  2687. \exdentamount=\lispnarrowing
  2688. \let\exdent=\nofillexdent
  2689. \let\nonarrowing=\relax
  2690. \fi
  2691. \parindent=0pt
  2692. \obeyspaces \obeylines \tt \rawbackslash
  2693. \gobble
  2694. }
  2695.  
  2696. % Define the \E... control sequence only if we are inside the
  2697. % environment, so the error checking in \end will work.
  2698. % We must call \lisp last in the definition, since it reads the
  2699. % return following the @example (or whatever) command.
  2700. %
  2701. \def\example{\begingroup \def\Eexample{\Elisp\endgroup}\lisp}
  2702. \def\smallexample{\begingroup \def\Esmallexample{\Elisp\endgroup}\lisp}
  2703.  
  2704. % Macro for 9 pt. examples, necessary to print with 5" lines.
  2705. % From Pavel@xerox.  This is not really used unless the
  2706. % @smallbook command is given.
  2707.  
  2708. \def\smalllispx{\aboveenvbreak\begingroup\inENV
  2709. %            This group ends at the end of the @lisp body
  2710. \hfuzz=12truept % Don't be fussy
  2711. % Make spaces be word-separators rather than space tokens.
  2712. \sepspaces %
  2713. % Single space lines
  2714. \singlespace %
  2715. % The following causes blank lines not to be ignored
  2716. % by adding a space to the end of each line.
  2717. \let\par=\lisppar
  2718. \def\Esmalllisp{\endgroup\afterenvbreak}%
  2719. %%%% Smaller baseline skip for small examples.
  2720. \baselineskip 10pt
  2721. \parskip=0pt
  2722. % @cartouche defines \nonarrowing to inhibit narrowing
  2723. % at next level down.
  2724. \ifx\nonarrowing\relax
  2725. \advance \leftskip by \lispnarrowing
  2726. \exdentamount=\lispnarrowing
  2727. \let\exdent=\nofillexdent
  2728. \let\nonarrowing=\relax
  2729. \fi
  2730. \parindent=0pt
  2731. \obeyspaces \obeylines \ninett \indexfonts \rawbackslash
  2732. \def\next##1{}\next}
  2733.  
  2734. % This is @display; same as @lisp except use roman font.
  2735.  
  2736. \def\display{\begingroup\inENV %This group ends at the end of the @display body
  2737. \aboveenvbreak
  2738. % Make spaces be word-separators rather than space tokens.
  2739. \sepspaces %
  2740. % Single space lines
  2741. \singlespace %
  2742. % The following causes blank lines not to be ignored
  2743. % by adding a space to the end of each line.
  2744. \let\par=\lisppar
  2745. \def\Edisplay{\endgroup\afterenvbreak}%
  2746. \parskip=0pt
  2747. % @cartouche defines \nonarrowing to inhibit narrowing
  2748. % at next level down.
  2749. \ifx\nonarrowing\relax
  2750. \advance \leftskip by \lispnarrowing
  2751. \exdentamount=\lispnarrowing
  2752. \let\exdent=\nofillexdent
  2753. \let\nonarrowing=\relax
  2754. \fi
  2755. \parindent=0pt
  2756. \obeyspaces \obeylines
  2757. \def\next##1{}\next}
  2758.  
  2759. % This is @format; same as @lisp except use roman font and don't narrow margins
  2760.  
  2761. \def\format{\begingroup\inENV %This group ends at the end of the @format body
  2762. \aboveenvbreak
  2763. % Make spaces be word-separators rather than space tokens.
  2764. \sepspaces %
  2765. \singlespace %
  2766. % The following causes blank lines not to be ignored
  2767. % by adding a space to the end of each line.
  2768. \let\par=\lisppar
  2769. \def\Eformat{\endgroup\afterenvbreak}
  2770. \parskip=0pt \parindent=0pt
  2771. \obeyspaces \obeylines
  2772. \def\next##1{}\next}
  2773.  
  2774. % @flushleft and @flushright
  2775.  
  2776. \def\flushleft{%
  2777. \begingroup\inENV %This group ends at the end of the @format body
  2778. \aboveenvbreak
  2779. % Make spaces be word-separators rather than space tokens.
  2780. \sepspaces %
  2781. % The following causes blank lines not to be ignored
  2782. % by adding a space to the end of each line.
  2783. % This also causes @ to work when the directive name
  2784. % is terminated by end of line.
  2785. \let\par=\lisppar
  2786. \def\Eflushleft{\endgroup\afterenvbreak}%
  2787. \parskip=0pt \parindent=0pt
  2788. \obeyspaces \obeylines
  2789. \def\next##1{}\next}
  2790.  
  2791. \def\flushright{%
  2792. \begingroup\inENV %This group ends at the end of the @format body
  2793. \aboveenvbreak
  2794. % Make spaces be word-separators rather than space tokens.
  2795. \sepspaces %
  2796. % The following causes blank lines not to be ignored
  2797. % by adding a space to the end of each line.
  2798. % This also causes @ to work when the directive name
  2799. % is terminated by end of line.
  2800. \let\par=\lisppar
  2801. \def\Eflushright{\endgroup\afterenvbreak}%
  2802. \parskip=0pt \parindent=0pt
  2803. \advance \leftskip by 0pt plus 1fill
  2804. \obeyspaces \obeylines
  2805. \def\next##1{}\next}
  2806.  
  2807. % @quotation - narrow the margins.
  2808.  
  2809. \def\quotation{%
  2810. \begingroup\inENV %This group ends at the end of the @quotation body
  2811. {\parskip=0pt  % because we will skip by \parskip too, later
  2812. \aboveenvbreak}%
  2813. \singlespace
  2814. \parindent=0pt
  2815. \def\Equotation{\par\endgroup\afterenvbreak}%
  2816. % @cartouche defines \nonarrowing to inhibit narrowing
  2817. % at next level down.
  2818. \ifx\nonarrowing\relax
  2819. \advance \leftskip by \lispnarrowing
  2820. \advance \rightskip by \lispnarrowing
  2821. \exdentamount=\lispnarrowing
  2822. \let\nonarrowing=\relax
  2823. \fi}
  2824.  
  2825. \message{defuns,}
  2826. % Define formatter for defuns
  2827. % First, allow user to change definition object font (\df) internally
  2828. \def\setdeffont #1 {\csname DEF#1\endcsname}
  2829.  
  2830. \newskip\defbodyindent \defbodyindent=.4in
  2831. \newskip\defargsindent \defargsindent=50pt
  2832. \newskip\deftypemargin \deftypemargin=12pt
  2833. \newskip\deflastargmargin \deflastargmargin=18pt
  2834.  
  2835. \newcount\parencount
  2836. % define \functionparens, which makes ( and ) and & do special things.
  2837. % \functionparens affects the group it is contained in.
  2838. \def\activeparens{%
  2839. \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
  2840. \catcode`\[=\active \catcode`\]=\active}
  2841.  
  2842. % Make control sequences which act like normal parenthesis chars.
  2843. \let\lparen = ( \let\rparen = )
  2844.  
  2845. {\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
  2846.  
  2847. % Be sure that we always have a definition for `(', etc.  For example,
  2848. % if the fn name has parens in it, \boldbrax will not be in effect yet,
  2849. % so TeX would otherwise complain about undefined control sequence.
  2850. \global\let(=\lparen \global\let)=\rparen
  2851. \global\let[=\lbrack \global\let]=\rbrack
  2852.  
  2853. \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
  2854. \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
  2855.  
  2856. % Definitions of (, ) and & used in args for functions.
  2857. % This is the definition of ( outside of all parentheses.
  2858. \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested %
  2859. \global\advance\parencount by 1 }
  2860. %
  2861. % This is the definition of ( when already inside a level of parens.
  2862. \gdef\opnested{\char`\(\global\advance\parencount by 1 }
  2863. %
  2864. \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
  2865. % also in that case restore the outer-level definition of (.
  2866. \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
  2867. \global\advance \parencount by -1 }
  2868. % If we encounter &foo, then turn on ()-hacking afterwards
  2869. \gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ }
  2870. %
  2871. \gdef\normalparens{\boldbrax\let&=\ampnr}
  2872. } % End of definition inside \activeparens
  2873. %% These parens (in \boldbrax) actually are a little bolder than the
  2874. %% contained text.  This is especially needed for [ and ]
  2875. \def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&}
  2876. \def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}}
  2877.  
  2878. % First, defname, which formats the header line itself.
  2879. % #1 should be the function name.
  2880. % #2 should be the type of definition, such as "Function".
  2881.  
  2882. \def\defname #1#2{%
  2883. % Get the values of \leftskip and \rightskip as they were
  2884. % outside the @def...
  2885. \dimen2=\leftskip
  2886. \advance\dimen2 by -\defbodyindent
  2887. \dimen3=\rightskip
  2888. \advance\dimen3 by -\defbodyindent
  2889. \noindent        %
  2890. \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
  2891. \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
  2892. \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
  2893. \parshape 2 0in \dimen0 \defargsindent \dimen1     %
  2894. % Now output arg 2 ("Function" or some such)
  2895. % ending at \deftypemargin from the right margin,
  2896. % but stuck inside a box of width 0 so it does not interfere with linebreaking
  2897. {% Adjust \hsize to exclude the ambient margins,
  2898. % so that \rightline will obey them.
  2899. \advance \hsize by -\dimen2 \advance \hsize by -\dimen3
  2900. \rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}%
  2901. % Make all lines underfull and no complaints:
  2902. \tolerance=10000 \hbadness=10000    
  2903. \advance\leftskip by -\defbodyindent
  2904. \exdentamount=\defbodyindent
  2905. {\df #1}\enskip        % Generate function name
  2906. }
  2907.  
  2908. % Actually process the body of a definition
  2909. % #1 should be the terminating control sequence, such as \Edefun.
  2910. % #2 should be the "another name" control sequence, such as \defunx.
  2911. % #3 should be the control sequence that actually processes the header,
  2912. %    such as \defunheader.
  2913.  
  2914. \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  2915. \medbreak %
  2916. % Define the end token that this defining construct specifies
  2917. % so that it will exit this group.
  2918. \def#1{\endgraf\endgroup\medbreak}%
  2919. \def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
  2920. \parindent=0in
  2921. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2922. \exdentamount=\defbodyindent
  2923. \begingroup %
  2924. \catcode 61=\active %
  2925. \obeylines\activeparens\spacesplit#3}
  2926.  
  2927. \def\defmethparsebody #1#2#3#4 {\begingroup\inENV %
  2928. \medbreak %
  2929. % Define the end token that this defining construct specifies
  2930. % so that it will exit this group.
  2931. \def#1{\endgraf\endgroup\medbreak}%
  2932. \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
  2933. \parindent=0in
  2934. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2935. \exdentamount=\defbodyindent
  2936. \begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
  2937.  
  2938. \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
  2939. \medbreak %
  2940. % Define the end token that this defining construct specifies
  2941. % so that it will exit this group.
  2942. \def#1{\endgraf\endgroup\medbreak}%
  2943. \def#2##1 ##2 {\def#4{##1}%
  2944. \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
  2945. \parindent=0in
  2946. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2947. \exdentamount=\defbodyindent
  2948. \begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
  2949.  
  2950. % These parsing functions are similar to the preceding ones
  2951. % except that they do not make parens into active characters.
  2952. % These are used for "variables" since they have no arguments.
  2953.  
  2954. \def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  2955. \medbreak %
  2956. % Define the end token that this defining construct specifies
  2957. % so that it will exit this group.
  2958. \def#1{\endgraf\endgroup\medbreak}%
  2959. \def#2{\begingroup\obeylines\spacesplit#3}%
  2960. \parindent=0in
  2961. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2962. \exdentamount=\defbodyindent
  2963. \begingroup %
  2964. \catcode 61=\active %
  2965. \obeylines\spacesplit#3}
  2966.  
  2967. \def\defvrparsebody #1#2#3#4 {\begingroup\inENV %
  2968. \medbreak %
  2969. % Define the end token that this defining construct specifies
  2970. % so that it will exit this group.
  2971. \def#1{\endgraf\endgroup\medbreak}%
  2972. \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
  2973. \parindent=0in
  2974. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2975. \exdentamount=\defbodyindent
  2976. \begingroup\obeylines\spacesplit{#3{#4}}}
  2977.  
  2978. % This seems to work right in all cases.
  2979. \let\deftpparsebody=\defvrparsebody
  2980. % This fails to work.  When given `@deftp {Data Type} foo_t',
  2981. % it thinks the type name is just `f'.
  2982. %%% This is the same as all the others except for the last line.  We need
  2983. %%% to parse the arguments differently for @deftp, since the ``attributes''
  2984. %%% there are optional.
  2985. %%% 
  2986. %%\def\deftpparsebody #1#2#3#4 {\begingroup\inENV %
  2987. %%\medbreak %
  2988. %%% Define the end token that this defining construct specifies
  2989. %%% so that it will exit this group.
  2990. %%\def#1{\endgraf\endgroup\medbreak}%
  2991. %%\def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
  2992. %%\parindent=0in
  2993. %%\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2994. %%\exdentamount=\defbodyindent
  2995. %%\begingroup\obeylines\parsetpheaderline{#3{#4}}}
  2996.  
  2997. %%{\obeylines %
  2998. %%  % Parse the type name and any attributes (field names, etc.).
  2999. %%  % #1 is the beginning of the macro call that will produce the output,
  3000. %%  %   i.e., \deftpheader{CLASS}; this is passed from \deftpparsebody.
  3001. %%  % #2 is the type name, e.g., `struct termios'.
  3002. %%  % #3 is the (possibly empty) attribute list.
  3003. %%  % 
  3004. %%  \gdef\parsetpheaderline#1#2#3^^M{%
  3005. %%    \endgroup % Started in \deftpparsebody.
  3006. %%    %
  3007. %%    % If the attribute list is in fact empty, there will be no space after
  3008. %%    % #2; so we can't put a space in our TeX parameter list.  But if it
  3009. %%    % isn't empty, then #3 will begin with an unwanted space.
  3010. %%    \def\theargs{\ignorespaces #3}%
  3011. %%    %
  3012. %%    % Call the macro to produce the output.
  3013. %%    #1{#2}\theargs %
  3014. %%  }%
  3015. %%}
  3016.  
  3017. \def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV %
  3018. \medbreak %
  3019. % Define the end token that this defining construct specifies
  3020. % so that it will exit this group.
  3021. \def#1{\endgraf\endgroup\medbreak}%
  3022. \def#2##1 ##2 {\def#4{##1}%
  3023. \begingroup\obeylines\spacesplit{#3{##2}}}%
  3024. \parindent=0in
  3025. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  3026. \exdentamount=\defbodyindent
  3027. \begingroup\obeylines\spacesplit{#3{#5}}}
  3028.  
  3029. % Split up #2 at the first space token.
  3030. % call #1 with two arguments:
  3031. %  the first is all of #2 before the space token,
  3032. %  the second is all of #2 after that space token.
  3033. % If #2 contains no space token, all of it is passed as the first arg
  3034. % and the second is passed as empty.
  3035.  
  3036. {\obeylines
  3037. \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
  3038. \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
  3039. \ifx\relax #3%
  3040. #1{#2}{}\else #1{#2}{#3#4}\fi}}
  3041.  
  3042. % So much for the things common to all kinds of definitions.
  3043.  
  3044. % Define @defun.
  3045.  
  3046. % First, define the processing that is wanted for arguments of \defun
  3047. % Use this to expand the args and terminate the paragraph they make up
  3048.  
  3049. \def\defunargs #1{\functionparens \sl
  3050. % Expand, preventing hyphenation at `-' chars.
  3051. % Note that groups don't affect changes in \hyphenchar.
  3052. \hyphenchar\tensl=0
  3053. #1%
  3054. \hyphenchar\tensl=45
  3055. \ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi%
  3056. \interlinepenalty=10000
  3057. \advance\rightskip by 0pt plus 1fil
  3058. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  3059. }
  3060.  
  3061. \def\deftypefunargs #1{%
  3062. % Expand, preventing hyphenation at `-' chars.
  3063. % Note that groups don't affect changes in \hyphenchar.
  3064. \functionparens
  3065. \code{#1}%
  3066. \interlinepenalty=10000
  3067. \advance\rightskip by 0pt plus 1fil
  3068. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  3069. }
  3070.  
  3071. % Do complete processing of one @defun or @defunx line already parsed.
  3072.  
  3073. % @deffn Command forward-char nchars
  3074.  
  3075. \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
  3076.  
  3077. \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
  3078. \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
  3079. \catcode 61=\other % Turn off change made in \defparsebody
  3080. }
  3081.  
  3082. % @defun == @deffn Function
  3083.  
  3084. \def\defun{\defparsebody\Edefun\defunx\defunheader}
  3085.  
  3086. \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  3087. \begingroup\defname {#1}{Function}%
  3088. \defunargs {#2}\endgroup %
  3089. \catcode 61=\other % Turn off change made in \defparsebody
  3090. }
  3091.  
  3092. % @deftypefun int foobar (int @var{foo}, float @var{bar})
  3093.  
  3094. \def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
  3095.  
  3096. % #1 is the data type.  #2 is the name and args.
  3097. \def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
  3098. % #1 is the data type, #2 the name, #3 the args.
  3099. \def\deftypefunheaderx #1#2 #3\relax{%
  3100. \doind {fn}{\code{#2}}% Make entry in function index
  3101. \begingroup\defname {\code{#1} #2}{Function}%
  3102. \deftypefunargs {#3}\endgroup %
  3103. \catcode 61=\other % Turn off change made in \defparsebody
  3104. }
  3105.  
  3106. % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
  3107.  
  3108. \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
  3109.  
  3110. % #1 is the classification.  #2 is the data type.  #3 is the name and args.
  3111. \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
  3112. % #1 is the classification, #2 the data type, #3 the name, #4 the args.
  3113. \def\deftypefnheaderx #1#2#3 #4\relax{%
  3114. \doind {fn}{\code{#3}}% Make entry in function index
  3115. \begingroup\defname {\code{#2} #3}{#1}%
  3116. \deftypefunargs {#4}\endgroup %
  3117. \catcode 61=\other % Turn off change made in \defparsebody
  3118. }
  3119.  
  3120. % @defmac == @deffn Macro
  3121.  
  3122. \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
  3123.  
  3124. \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  3125. \begingroup\defname {#1}{Macro}%
  3126. \defunargs {#2}\endgroup %
  3127. \catcode 61=\other % Turn off change made in \defparsebody
  3128. }
  3129.  
  3130. % @defspec == @deffn Special Form
  3131.  
  3132. \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
  3133.  
  3134. \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  3135. \begingroup\defname {#1}{Special Form}%
  3136. \defunargs {#2}\endgroup %
  3137. \catcode 61=\other % Turn off change made in \defparsebody
  3138. }
  3139.  
  3140. % This definition is run if you use @defunx
  3141. % anywhere other than immediately after a @defun or @defunx.
  3142.  
  3143. \def\deffnx #1 {\errmessage{@deffnx in invalid context}}
  3144. \def\defunx #1 {\errmessage{@defunx in invalid context}}
  3145. \def\defmacx #1 {\errmessage{@defmacx in invalid context}}
  3146. \def\defspecx #1 {\errmessage{@defspecx in invalid context}}
  3147. \def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}}
  3148. \def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}}
  3149.  
  3150. % @defmethod, and so on
  3151.  
  3152. % @defop {Funny Method} foo-class frobnicate argument
  3153.  
  3154. \def\defop #1 {\def\defoptype{#1}%
  3155. \defopparsebody\Edefop\defopx\defopheader\defoptype}
  3156.  
  3157. \def\defopheader #1#2#3{%
  3158. \dosubind {fn}{\code{#2}}{on #1}% Make entry in function index
  3159. \begingroup\defname {#2}{\defoptype{} on #1}%
  3160. \defunargs {#3}\endgroup %
  3161. }
  3162.  
  3163. % @defmethod == @defop Method
  3164.  
  3165. \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
  3166.  
  3167. \def\defmethodheader #1#2#3{%
  3168. \dosubind {fn}{\code{#2}}{on #1}% entry in function index
  3169. \begingroup\defname {#2}{Method on #1}%
  3170. \defunargs {#3}\endgroup %
  3171. }
  3172.  
  3173. % @defcv {Class Option} foo-class foo-flag
  3174.  
  3175. \def\defcv #1 {\def\defcvtype{#1}%
  3176. \defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
  3177.  
  3178. \def\defcvarheader #1#2#3{%
  3179. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  3180. \begingroup\defname {#2}{\defcvtype{} of #1}%
  3181. \defvarargs {#3}\endgroup %
  3182. }
  3183.  
  3184. % @defivar == @defcv {Instance Variable}
  3185.  
  3186. \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
  3187.  
  3188. \def\defivarheader #1#2#3{%
  3189. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  3190. \begingroup\defname {#2}{Instance Variable of #1}%
  3191. \defvarargs {#3}\endgroup %
  3192. }
  3193.  
  3194. % These definitions are run if you use @defmethodx, etc.,
  3195. % anywhere other than immediately after a @defmethod, etc.
  3196.  
  3197. \def\defopx #1 {\errmessage{@defopx in invalid context}}
  3198. \def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
  3199. \def\defcvx #1 {\errmessage{@defcvx in invalid context}}
  3200. \def\defivarx #1 {\errmessage{@defivarx in invalid context}}
  3201.  
  3202. % Now @defvar
  3203.  
  3204. % First, define the processing that is wanted for arguments of @defvar.
  3205. % This is actually simple: just print them in roman.
  3206. % This must expand the args and terminate the paragraph they make up
  3207. \def\defvarargs #1{\normalparens #1%
  3208. \interlinepenalty=10000
  3209. \endgraf\penalty 10000\vskip -\parskip\penalty 10000}
  3210.  
  3211. % @defvr Counter foo-count
  3212.  
  3213. \def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
  3214.  
  3215. \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
  3216. \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
  3217.  
  3218. % @defvar == @defvr Variable
  3219.  
  3220. \def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
  3221.  
  3222. \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  3223. \begingroup\defname {#1}{Variable}%
  3224. \defvarargs {#2}\endgroup %
  3225. }
  3226.  
  3227. % @defopt == @defvr {User Option}
  3228.  
  3229. \def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
  3230.  
  3231. \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  3232. \begingroup\defname {#1}{User Option}%
  3233. \defvarargs {#2}\endgroup %
  3234. }
  3235.  
  3236. % @deftypevar int foobar
  3237.  
  3238. \def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
  3239.  
  3240. % #1 is the data type.  #2 is the name.
  3241. \def\deftypevarheader #1#2{%
  3242. \doind {vr}{\code{#2}}% Make entry in variables index
  3243. \begingroup\defname {\code{#1} #2}{Variable}%
  3244. \interlinepenalty=10000
  3245. \endgraf\penalty 10000\vskip -\parskip\penalty 10000
  3246. \endgroup}
  3247.  
  3248. % @deftypevr {Global Flag} int enable
  3249.  
  3250. \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
  3251.  
  3252. \def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}%
  3253. \begingroup\defname {\code{#2} #3}{#1}
  3254. \interlinepenalty=10000
  3255. \endgraf\penalty 10000\vskip -\parskip\penalty 10000
  3256. \endgroup}
  3257.  
  3258. % This definition is run if you use @defvarx
  3259. % anywhere other than immediately after a @defvar or @defvarx.
  3260.  
  3261. \def\defvrx #1 {\errmessage{@defvrx in invalid context}}
  3262. \def\defvarx #1 {\errmessage{@defvarx in invalid context}}
  3263. \def\defoptx #1 {\errmessage{@defoptx in invalid context}}
  3264. \def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}}
  3265. \def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}}
  3266.  
  3267. % Now define @deftp
  3268. % Args are printed in bold, a slight difference from @defvar.
  3269.  
  3270. \def\deftpargs #1{\bf \defvarargs{#1}}
  3271.  
  3272. % @deftp Class window height width ...
  3273.  
  3274. \def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader}
  3275.  
  3276. \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
  3277. \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
  3278.  
  3279. % This definition is run if you use @deftpx, etc
  3280. % anywhere other than immediately after a @deftp, etc.
  3281.  
  3282. \def\deftpx #1 {\errmessage{@deftpx in invalid context}}
  3283.  
  3284. \message{cross reference,}
  3285. % Define cross-reference macros
  3286. \newwrite \auxfile
  3287.  
  3288. \newif\ifhavexrefs  % True if xref values are known.
  3289. \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
  3290.  
  3291. % \setref{foo} defines a cross-reference point named foo.
  3292.  
  3293. \def\setref#1{%
  3294. %\dosetq{#1-title}{Ytitle}%
  3295. \dosetq{#1-pg}{Ypagenumber}%
  3296. \dosetq{#1-snt}{Ysectionnumberandtype}}
  3297.  
  3298. \def\unnumbsetref#1{%
  3299. %\dosetq{#1-title}{Ytitle}%
  3300. \dosetq{#1-pg}{Ypagenumber}%
  3301. \dosetq{#1-snt}{Ynothing}}
  3302.  
  3303. \def\appendixsetref#1{%
  3304. %\dosetq{#1-title}{Ytitle}%
  3305. \dosetq{#1-pg}{Ypagenumber}%
  3306. \dosetq{#1-snt}{Yappendixletterandtype}}
  3307.  
  3308. % \xref, \pxref, and \ref generate cross-references to specified points.
  3309. % For \xrefX, #1 is the node name, #2 the name of the Info
  3310. % cross-reference, #3 the printed node name, #4 the name of the Info
  3311. % file, #5 the name of the printed manual.  All but the node name can be
  3312. % omitted.
  3313. \def\pxref#1{see \xrefX[#1,,,,,,,]}
  3314. \def\xref#1{See \xrefX[#1,,,,,,,]}
  3315. \def\ref#1{\xrefX[#1,,,,,,,]}
  3316. \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup%
  3317. \def\printedmanual{\ignorespaces #5}%
  3318. \def\printednodename{\ignorespaces #3}%
  3319. %
  3320. \setbox1=\hbox{\printedmanual}%
  3321. \setbox0=\hbox{\printednodename}%
  3322. \ifdim \wd0=0pt%
  3323. \def\printednodename{\ignorespaces #1}%
  3324. %%% Uncommment the following line to make the actual chapter or section title
  3325. %%% appear inside the square brackets.
  3326. %\def\printednodename{#1-title}%
  3327. \fi%
  3328. %
  3329. %
  3330. % If we use \unhbox0 and \unhbox1 to print the node names, TeX does
  3331. % not insert empty discretionaries after hyphens, which means that it
  3332. % will not find a line break at a hyphen in a node names.  Since some
  3333. % manuals are best written with fairly long node names, containing
  3334. % hyphens, this is a loss.  Therefore, we simply give the text of
  3335. % the node name again, so it is as if TeX is seeing it for the first
  3336. % time.
  3337. \ifdim \wd1>0pt
  3338. section ``\printednodename'' in \cite{\printedmanual}%
  3339. \else%
  3340. \turnoffactive%
  3341. \refx{#1-snt}{} [\printednodename], page\tie\refx{#1-pg}{}%
  3342. \fi
  3343. \endgroup}
  3344.  
  3345. % \dosetq is the interface for calls from other macros
  3346.  
  3347. % Use \turnoffactive so that punctuation chars such as underscore
  3348. % work in node names.
  3349. \def\dosetq #1#2{{\let\folio=0 \turnoffactive%
  3350. \edef\next{\write\auxfile{\internalsetq {#1}{#2}}}%
  3351. \next}}
  3352.  
  3353. % \internalsetq {foo}{page} expands into
  3354. % CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
  3355. % When the aux file is read, ' is the escape character
  3356.  
  3357. \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
  3358.  
  3359. % Things to be expanded by \internalsetq
  3360.  
  3361. \def\Ypagenumber{\folio}
  3362.  
  3363. \def\Ytitle{\thischapter}
  3364.  
  3365. \def\Ynothing{}
  3366.  
  3367. \def\Ysectionnumberandtype{%
  3368. \ifnum\secno=0 Chapter\xreftie\the\chapno %
  3369. \else \ifnum \subsecno=0 Section\xreftie\the\chapno.\the\secno %
  3370. \else \ifnum \subsubsecno=0 %
  3371. Section\xreftie\the\chapno.\the\secno.\the\subsecno %
  3372. \else %
  3373. Section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
  3374. \fi \fi \fi }
  3375.  
  3376. \def\Yappendixletterandtype{%
  3377. \ifnum\secno=0 Appendix\xreftie'char\the\appendixno{}%
  3378. \else \ifnum \subsecno=0 Section\xreftie'char\the\appendixno.\the\secno %
  3379. \else \ifnum \subsubsecno=0 %
  3380. Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
  3381. \else %
  3382. Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
  3383. \fi \fi \fi }
  3384.  
  3385. \gdef\xreftie{'tie}
  3386.  
  3387. % Use TeX 3.0's \inputlineno to get the line number, for better error
  3388. % messages, but if we're using an old version of TeX, don't do anything.
  3389. \ifx\inputlineno\thisisundefined
  3390.   \let\linenumber = \empty % Non-3.0.
  3391. \else
  3392.   \def\linenumber{\the\inputlineno:\space}
  3393. \fi
  3394.  
  3395. % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
  3396. % If its value is nonempty, SUFFIX is output afterward.
  3397.  
  3398. \def\refx#1#2{%
  3399.   \expandafter\ifx\csname X#1\endcsname\relax
  3400.     % If not defined, say something at least.
  3401.     $\langle$un\-de\-fined$\rangle$%
  3402.     \ifhavexrefs
  3403.       \message{\linenumber Undefined cross reference `#1'.}%
  3404.     \else
  3405.       \ifwarnedxrefs\else
  3406.         \global\warnedxrefstrue
  3407.         \message{Cross reference values unknown; you must run TeX again.}%
  3408.       \fi
  3409.     \fi
  3410.   \else
  3411.     % It's defined, so just use it.
  3412.     \csname X#1\endcsname
  3413.   \fi
  3414.   #2% Output the suffix in any case.
  3415. }
  3416.  
  3417. % Read the last existing aux file, if any.  No error if none exists.
  3418.  
  3419. % This is the macro invoked by entries in the aux file.
  3420. \def\xrdef #1#2{
  3421. {\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}}
  3422.  
  3423. \def\readauxfile{%
  3424. \begingroup
  3425. \catcode `\^^@=\other
  3426. \catcode `\⇧=\other
  3427. \catcode `\⇩=\other
  3428. \catcode `\^^C=\other
  3429. \catcode `\^^D=\other
  3430. \catcode `\^^E=\other
  3431. \catcode `\^^F=\other
  3432. \catcode `\^^G=\other
  3433. \catcode `\^^H=\other
  3434. \catcode `\♪=\other
  3435. \catcode `\^^L=\other
  3436. \catcode `\=\other
  3437. \catcode `\=\other
  3438. \catcode `\⓪=\other
  3439. \catcode `\①=\other
  3440. \catcode `\②=\other
  3441. \catcode `\③=\other
  3442. \catcode `\④=\other
  3443. \catcode `\⑤=\other
  3444. \catcode `\⑥=\other
  3445. \catcode `\⑦=\other
  3446. \catcode `\⑧=\other
  3447. \catcode `\⑨=\other
  3448. \catcode 26=\other
  3449. \catcode `\^^[=\other
  3450. \catcode `\^^\=\other
  3451. \catcode `\^^]=\other
  3452. \catcode `\^^^=\other
  3453. \catcode `\^^_=\other
  3454. \catcode `\@=\other
  3455. \catcode `\^=\other
  3456. \catcode `\~=\other
  3457. \catcode `\[=\other
  3458. \catcode `\]=\other
  3459. \catcode`\"=\other
  3460. \catcode`\_=\other
  3461. \catcode`\|=\other
  3462. \catcode`\<=\other
  3463. \catcode`\>=\other
  3464. \catcode `\$=\other
  3465. \catcode `\#=\other
  3466. \catcode `\&=\other
  3467. % `\+ does not work, so use 43.
  3468. \catcode 43=\other
  3469. % the aux file uses ' as the escape.
  3470. % Turn off \ as an escape so we do not lose on
  3471. % entries which were dumped with control sequences in their names.
  3472. % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
  3473. % Reference to such entries still does not work the way one would wish,
  3474. % but at least they do not bomb out when the aux file is read in.
  3475. \catcode `\{=1 \catcode `\}=2
  3476. \catcode `\%=\other
  3477. \catcode `\'=0
  3478. \catcode `\\=\other
  3479. \openin 1 \jobname.aux
  3480. \ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue
  3481. \fi
  3482. % Open the new aux file.  Tex will close it automatically at exit.
  3483. \openout \auxfile=\jobname.aux
  3484. \endgroup}
  3485.  
  3486.  
  3487. % Footnotes.
  3488.  
  3489. \newcount \footnoteno
  3490.  
  3491. % The trailing space in the following definition for supereject is
  3492. % vital for proper filling; pages come out unaligned when you do a
  3493. % pagealignmacro call if that space before the closing brace is
  3494. % removed.
  3495. \def\supereject{\par\penalty -20000\footnoteno =0 }
  3496.  
  3497. % @footnotestyle is meaningful for info output only..
  3498. \let\footnotestyle=\comment
  3499.  
  3500. \let\ptexfootnote=\footnote
  3501.  
  3502. {\catcode `\@=11
  3503. \long\gdef\footnote #1{\global\advance \footnoteno by \@ne
  3504. \unskip
  3505. \edef\thisfootno{$^{\the\footnoteno}$}%
  3506. \let\@sf\empty
  3507. \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
  3508. \thisfootno\@sf \footnotezzz{#1}}
  3509. % \parsearg\footnotezzz}
  3510.  
  3511. \long\gdef\footnotezzz #1{\insert\footins{
  3512. \interlinepenalty\interfootnotelinepenalty
  3513. \splittopskip\ht\strutbox % top baseline for broken footnotes
  3514. \splitmaxdepth\dp\strutbox \floatingpenalty\@MM
  3515. \leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip
  3516. \footstrut\parindent=\defaultparindent\hang\textindent{\thisfootno}#1\strut}}
  3517.  
  3518. }%end \catcode `\@=11
  3519.  
  3520. % Set the baselineskip to #1, and the lineskip and strut size
  3521. % correspondingly.  There is no deep meaning behind these magic numbers
  3522. % used as factors; they just match (closely enough) what Knuth defined.
  3523. \def\lineskipfactor{.1}
  3524. \def\strutheightpercent{.71}
  3525. \def\strutdepthpercent{.29}
  3526. %
  3527. \def\setleading#1{%
  3528.   \baselineskip = #1\relax
  3529.   \normalbaselineskip = \baselineskip
  3530.   \lineskip = \lineskipfactor\baselineskip
  3531.   \setbox\strutbox =\hbox{%
  3532.     \vrule width0pt height\strutheightpercent\baselineskip
  3533.                     depth \strutdepthpercent \baselineskip
  3534.   }%
  3535. }
  3536.  
  3537. % @| inserts a changebar to the left of the current line.  It should
  3538. % surround any changed text.  This approach does *not* work if the
  3539. % change spans more than two lines of output.  To handle that, we would
  3540. % have adopt a much more difficult approach (putting marks into the main
  3541. % vertical list for the beginning and end of each change).
  3542. \def\|{%
  3543.   % \vadjust can only be used in horizontal mode.
  3544.   \leavevmode
  3545.   %
  3546.   % Append this vertical mode material after the current line in the output.
  3547.   \vadjust{%
  3548.     % We want to insert a rule with the height and depth of the current
  3549.     % leading; that is exactly what \strutbox is supposed to record.
  3550.     \vskip-\baselineskip
  3551.     %
  3552.     % \vadjust-items are inserted at the left edge of the type.  So
  3553.     % the \llap here moves out into the left-hand margin.
  3554.     \llap{%
  3555.       %
  3556.       % For a thicker or thinner bar, change the `1pt'.
  3557.       \vrule height\baselineskip width1pt
  3558.       %
  3559.       % This is the space between the bar and the text.
  3560.       \hskip 12pt
  3561.     }%
  3562.   }%
  3563. }
  3564.  
  3565. % For a final copy, take out the rectangles
  3566. % that mark overfull boxes (in case you have decided
  3567. % that the text looks ok even though it passes the margin).
  3568. \def\finalout{\overfullrule=0pt}
  3569.  
  3570.  
  3571. % End of control word definitions.
  3572.  
  3573. \message{and turning on texinfo input format.}
  3574.  
  3575. \def\openindices{%
  3576.    \newindex{cp}%
  3577.    \newcodeindex{fn}%
  3578.    \newcodeindex{vr}%
  3579.    \newcodeindex{tp}%
  3580.    \newcodeindex{ky}%
  3581.    \newcodeindex{pg}%
  3582. }
  3583.  
  3584. % Set some numeric style parameters, for 8.5 x 11 format.
  3585.  
  3586. %\hsize = 6.5in
  3587. \newdimen\defaultparindent \defaultparindent = 15pt
  3588. \parindent = \defaultparindent
  3589. \parskip 18pt plus 1pt
  3590. \setleading{15pt}
  3591. \advance\topskip by 1.2cm
  3592.  
  3593. % Prevent underfull vbox error messages.
  3594. \vbadness=10000
  3595.  
  3596. % Following George Bush, just get rid of widows and orphans.
  3597. \widowpenalty=10000
  3598. \clubpenalty=10000
  3599.  
  3600. % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
  3601. % using an old version of TeX, don't do anything.  We want the amount of
  3602. % stretch added to depend on the line length, hence the dependence on
  3603. % \hsize.  This makes it come to about 9pt for the 8.5x11 format.
  3604. \ifx\emergencystretch\thisisundefined \else
  3605.   \emergencystretch = \hsize
  3606.   \divide\emergencystretch by 45
  3607. \fi
  3608.  
  3609. % Use @smallbook to reset parameters for 7x9.5 format  (or else 7x9.25)
  3610. \def\smallbook{
  3611.  
  3612. % These values for secheadingskip and subsecheadingskip are
  3613. % experiments.  RJC 7 Aug 1992
  3614. \global\secheadingskip = 17pt plus 6pt minus 3pt
  3615. \global\subsecheadingskip = 14pt plus 6pt minus 3pt
  3616.  
  3617. \global\lispnarrowing = 0.3in
  3618. \setleading{12pt}
  3619. \advance\topskip by -1cm
  3620. \global\parskip 3pt plus 1pt
  3621. \global\hsize = 5in
  3622. \global\vsize=7.5in
  3623. \global\tolerance=700
  3624. \global\hfuzz=1pt
  3625. \global\contentsrightmargin=0pt
  3626.  
  3627. \global\pagewidth=\hsize
  3628. \global\pageheight=\vsize
  3629.  
  3630. \global\let\smalllisp=\smalllispx
  3631. \global\let\smallexample=\smalllispx
  3632. \global\def\Esmallexample{\Esmalllisp}
  3633. }
  3634.  
  3635. % Use @afourpaper to print on European A4 paper.
  3636. \def\afourpaper{
  3637. \global\tolerance=700
  3638. \global\hfuzz=1pt
  3639. \setleading{12pt}
  3640. \global\parskip 15pt plus 1pt
  3641.  
  3642. \global\vsize= 53\baselineskip
  3643. \advance\vsize by \topskip
  3644. %\global\hsize=   5.85in     % A4 wide 10pt
  3645. \global\hsize=  6.5in
  3646. \global\outerhsize=\hsize
  3647. \global\advance\outerhsize by 0.5in
  3648. \global\outervsize=\vsize
  3649. \global\advance\outervsize by 0.6in
  3650.  
  3651. \global\pagewidth=\hsize
  3652. \global\pageheight=\vsize
  3653. }
  3654.  
  3655. % Define macros to output various characters with catcode for normal text.
  3656. \catcode`\"=\other
  3657. \catcode`\~=\other
  3658. \catcode`\^=\other
  3659. \catcode`\_=\other
  3660. \catcode`\|=\other
  3661. \catcode`\<=\other
  3662. \catcode`\>=\other
  3663. \catcode`\+=\other
  3664. \def\normaldoublequote{"}
  3665. \def\normaltilde{~}
  3666. \def\normalcaret{^}
  3667. \def\normalunderscore{_}
  3668. \def\normalverticalbar{|}
  3669. \def\normalless{<}
  3670. \def\normalgreater{>}
  3671. \def\normalplus{+}
  3672.  
  3673. % This macro is used to make a character print one way in ttfont
  3674. % where it can probably just be output, and another way in other fonts,
  3675. % where something hairier probably needs to be done.
  3676. %
  3677. % #1 is what to print if we are indeed using \tt; #2 is what to print
  3678. % otherwise.  Since all the Computer Modern typewriter fonts have zero
  3679. % interword stretch (and shrink), and it is reasonable to expect all
  3680. % typewriter fonts to have this, we can check that font parameter.
  3681. \def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi}
  3682.  
  3683. % Turn off all special characters except @
  3684. % (and those which the user can use as if they were ordinary).
  3685. % Most of these we simply print from the \tt font, but for some, we can
  3686. % use math or other variants that look better in normal text.
  3687.  
  3688. \catcode`\"=\active
  3689. \def\activedoublequote{{\tt \char '042}}
  3690. \let"=\activedoublequote
  3691. \catcode`\~=\active
  3692. \def~{{\tt \char '176}}
  3693. \chardef\hat=`\^
  3694. \catcode`\^=\active
  3695. \def^{{\tt \hat}}
  3696.  
  3697. \catcode`\_=\active
  3698. \def_{\ifusingtt\normalunderscore\_}
  3699. % Subroutine for the previous macro.
  3700. \def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}}
  3701.  
  3702. % \lvvmode is equivalent in function to \leavevmode.
  3703. % Using \leavevmode runs into trouble when written out to
  3704. % an index file due to the expansion of \leavevmode into ``\unhbox
  3705. % \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our
  3706. % magic tricks with @.
  3707. \def\lvvmode{\vbox to 0pt{}}
  3708.  
  3709. \catcode`\|=\active
  3710. \def|{{\tt \char '174}}
  3711. \chardef \less=`\<
  3712. \catcode`\<=\active
  3713. \def<{{\tt \less}}
  3714. \chardef \gtr=`\>
  3715. \catcode`\>=\active
  3716. \def>{{\tt \gtr}}
  3717. \catcode`\+=\active
  3718. \def+{{\tt \char 43}}
  3719. %\catcode 27=\active
  3720. %\def^^[{$\diamondsuit$}
  3721.  
  3722. % Used sometimes to turn off (effectively) the active characters
  3723. % even after parsing them.
  3724. \def\turnoffactive{\let"=\normaldoublequote
  3725. \let~=\normaltilde
  3726. \let^=\normalcaret
  3727. \let_=\normalunderscore
  3728. \let|=\normalverticalbar
  3729. \let<=\normalless
  3730. \let>=\normalgreater
  3731. \let+=\normalplus}
  3732.  
  3733. % Set up an active definition for =, but don't enable it most of the time.
  3734. {\catcode`\==\active
  3735. \global\def={{\tt \char 61}}}
  3736.  
  3737. \catcode`\@=0
  3738.  
  3739. % \rawbackslashxx output one backslash character in current font
  3740. \global\chardef\rawbackslashxx=`\\
  3741. %{\catcode`\\=\other
  3742. %@gdef@rawbackslashxx{\}}
  3743.  
  3744. % \rawbackslash redefines \ as input to do \rawbackslashxx.
  3745. {\catcode`\\=\active
  3746. @gdef@rawbackslash{@let\=@rawbackslashxx }}
  3747.  
  3748. % \normalbackslash outputs one backslash in fixed width font.
  3749. \def\normalbackslash{{\tt\rawbackslashxx}}
  3750.  
  3751. % Say @foo, not \foo, in error messages.
  3752. \escapechar=`\@
  3753.  
  3754. % \catcode 17=0   % Define control-q
  3755. \catcode`\\=\active
  3756.  
  3757. % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
  3758. % That is what \eatinput is for; after that, the `\' should revert to printing 
  3759. % a backslash.
  3760. %
  3761. @gdef@eatinput input texinfo{@fixbackslash}
  3762. @global@let\ = @eatinput
  3763.  
  3764. % On the other hand, perhaps the file did not have a `\input texinfo'. Then
  3765. % the first `\{ in the file would cause an error. This macro tries to fix 
  3766. % that, assuming it is called before the first `\' could plausibly occur.
  3767. @gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi}
  3768.  
  3769. %% These look ok in all fonts, so just make them not special.  The @rm below
  3770. %% makes sure that the current font starts out as the newly loaded cmr10
  3771. @catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other
  3772.  
  3773. @textfonts
  3774. @rm
  3775.  
  3776. @c Local variables:
  3777. @c page-delimiter: "^\\\\message"
  3778. @c End:
  3779.